logo

【Forum】Improve Default Cache Plugin of Joomla 3.5 ~ FusoElektronique

Community and Web Radio of Electronic Music, Art, Culture, Design, DIY, Events, Free Productions, Politics, Technology.

FusoElektronique ~ Forum

file Improve Default Cache Plugin of Joomla 3.5

01 Apr 2016 15:19 - 08 Apr 2016 17:53 #1 by Trony
Trony created the topic: Improve Default Cache Plugin of Joomla 3.5


Joomla 3.5 with Default Cache Plugin Enabled, change Header when the pages are Cached.
No Cached Pages: Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Cached Pages: Cache-Control: no-cache

You can check your Header with Redbot .

With this Hack, we force CMS to stay with the Default Header (Cached and No Cached Pages).

WARNING: It's a Joomla Hack Core. BACKUP ALWAYS AND FOREVER !!!


First Step
Open your index.php of your template and put this code at the top
<?php
jimport('joomla.environment.response');
JResponse::allowCache(true);
$time = time()- 1;
JResponse::setHeader('Last-Modified', gmdate('D, d M Y H:i:s', $time) . ' GMT', true);
JResponse::setHeader('Expires', 'Wed, 17 Aug 2005 00:00:00 GMT', true);
JResponse::setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0', false );
JResponse::setHeader('Pragma', 'no-cache', true );
?>

Second Step
Open web.php in librariesjoomlaapplication
and comment with // this part of the code:
// If the response is set to uncachable, we need to set some appropriate headers so browsers don't cache the response.
		if (!$this->response->cachable)
		{
			// Expires in the past.
			//$this->setHeader('Expires', 'Wed, 17 Aug 2005 00:00:00 GMT', true);

			// Always modified.
			// $this->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
			// $this->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);

			// HTTP 1.0
			$this->setHeader('Pragma', 'no-cache');
		}
		else
		{
			// Expires.
			// $this->setHeader('Expires', gmdate('D, d M Y H:i:s', time() + 900) . ' GMT');

			// Last modified.
			if ($this->modifiedDate instanceof JDate)
			{
				$this->setHeader('Last-Modified', $this->modifiedDate->format('D, d M Y H:i:s'));
			}
		}

Third Step
Open page.php in librariescachecontroller
and at the end:
/**
	 * Set the ETag header in the response
	 *
	 * @param   string  $etag  The entity tag (etag) to set
	 *
	 * @return  void
	 *
	 * @since   11.1
	 */
	protected function _setEtag($etag)
	{
	       jimport('joomla.environment.response');
               JResponse::allowCache(true);
               JResponse::setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0', false );
	       JResponse::setHeader('Pragma', 'no-cache', true );
	       $etagFuso = md5($id);
	       JResponse::setHeader('ETag', 'W/"'.$etagFuso.'"', true );
		
	}
	
}

Note:
I used $etagFuso because Joomla give URL instead number.
Weak eTag (W/) is for Compressed and Non-Compressed Gzip Pages.


Now check with Redbot the Header of your Joomla's page.
Music and Electronic Devices Designer. Drum and Bass Addict. Creative Mind as Lifestyle. Cat in past Life. Soccer, Ice Hockey and Snowboard Lover. Marxist.
Sono Il Re sul Carro Danzante. Attraversando La Città Getto Via I Coriandoli Della Vostra Tristezza Regalando Passione Ed Estasi Nei Vostri Occhi.
Follow Trony on: FusoElektronique | Facebook | Twitter | Google+ | Soundcloud

Attachments:

Last Edit: 08 Apr 2016 17:53 by Trony.

Please Log in or Create an account to join the conversation.

Web Hosting

Please. Leave a Vote at this Topic.

Moderators: Trony
【Forum】Improve Default Cache Plugin of Joomla 3.5 ~ FusoElektronique Page 1 | Improve Default Cache Plugin of Joomla 3.5. Published by Trony on Friday, 01 April 2016 in Computers - WebMastering - Consolle (Design's Factory)
0
Time to create page: 0.298 seconds

Come and Follow Us

Do You Love Electronic Music ?!?

Do You like Technology and Design ?!?

Are You a Dj / Producer / PR and more... ?!?

Do You Want Promote Yourself for FREE ?!?

Join in the our Community... Register !!!

If You have an Account, Login and Share with Us your Electronic's Culture

FusoElektronique ~ Pure Electronic Music FusoElektronique
FusoElektronique ~ Pure Electronic Music