Preventing Joomla! from sending no-cache in headers

If you are using Joomla! 1.5+ and trying to cache with nginx or other caching server and at same time you don’t want to use Joomla! system cache plugin. You’ll face a big problem, that Joomla! is sending “Cache-Control: no-cache” and “Pragma: no-cache” in response headers.

Here’s the solution :

1. Edit the following file :

Joomla root/libraries/joomla/environment/response.php

2. Search for the following code :

if (self::allowCache() === false) {
self::setHeader('Cache-Control', 'no-cache', false);
// HTTP 1.0
self::setHeader('Pragma', 'no-cache');
}

3. Comment this if condition, to be as follows

/*
if (self::allowCache() === false) {
self::setHeader('Cache-Control', 'no-cache', false);
// HTTP 1.0
self::setHeader('Pragma', 'no-cache');
}
*/

Now, you can disable Joomla! caching, and run whatever caching server, as nginx.

2 Comments

  • Thanks for the tip, I think I might take a loot at this in the future as Joomla caching doesn’t satisfy my needs at the moment.

    • Yes, actually we faced some issues with Parliament & Presidential elections :) and am trying to share it as early as I can.

Leave a comment

 

WP-SpamFree by Pole Position Marketing