Pagespeed caching css, annoying to develop
Asked Answered
F

9

28

I'm working on a site which I havent coded from scratch and in firebug the css files are being displayed as: style.css.pagespeed.ce.5d2Z68nynm.css with the pagespeed extension. Can anyone tell me what's doing this as I can't find it. I'm guessing mod-pagespeed possibly running on server? I want to turn it off for now because it's caching my css and stopping updates which is really annoying to develop with.

Thanks in advance.

Faery answered 14/2, 2011 at 21:0 Comment(3)
The filename has a md5 reference, so if you change the contents of the file, the url will be different and will be requested. So it doesn't matter that pagepspeed caches the file as if you edit it it will be a different file to pagespeed.Biltong
@Biltong - The code doesn't seem to work perfectly, as I have FTP'ed files up, confirmed that they are changed, and pagespeed still served the old content.Saffron
You could have your html cached downstream. But barring that have you setup static file locations? By default it doesn't know where your static files are so relies on fetching them via http. If you setup static files it will recognize the changeBiltong
A
28

According to http://code.google.com/speed/page-speed/docs/using_mod.html#htaccess you can turn off the module with the line ModPagespeed off in a .htaccess file.

The best solution would be to have a non-live development environment that didn't have mod_pagespeed on at all, or where it could be added only for some final testing.

Ayesha answered 14/2, 2011 at 21:10 Comment(1)
This fixed it for me too. Mine was on a Bitnami Wordpress machine and I found it at: ~/stack/apache2/conf I also had to reboot my server to get it to work (though restarting apache probably would have as well, but I didn't know how to do that!)Saffron
W
32

Alister is right. There are other two ways I know to do this. With a .htaccess shared through many domains and you want to disable PageSpeed only on a single domain, you can add to the bottom of the .htaccess file:

<IfModule pagespeed_module>
  ...
  ModPagespeedDisallow http://www.example.com/*
</IfModule>

It means that you can have two domains, one for the developement (ModPagespeedDisallow) and one with ModPagespeed active. Never tried but should it works, avoiding visitor getting a not optimized page during development.

Or you can add ?ModPagespeed=off to the url as stated on mod_pagespeed FAQ.

Writer answered 18/4, 2012 at 8:5 Comment(0)
A
28

According to http://code.google.com/speed/page-speed/docs/using_mod.html#htaccess you can turn off the module with the line ModPagespeed off in a .htaccess file.

The best solution would be to have a non-live development environment that didn't have mod_pagespeed on at all, or where it could be added only for some final testing.

Ayesha answered 14/2, 2011 at 21:10 Comment(1)
This fixed it for me too. Mine was on a Bitnami Wordpress machine and I found it at: ~/stack/apache2/conf I also had to reboot my server to get it to work (though restarting apache probably would have as well, but I didn't know how to do that!)Saffron
P
9

Another option for resetting the cache is described here:

Find out where is the cache folder, it's defined in the config file under ModPagespeedFileCachePath property.

Then run the following command from shell:

touch <path_to_pagespeed_cache>/cache.flush
(In my case: touch /var/cache/mod_pagespeed/cache.flush)

That's it. The cache was reset.

Plenteous answered 16/7, 2016 at 19:40 Comment(1)
No idea why this is not the preferred answer: retains all the benefits of mod_pagespeed, but enables trigger of a cache rebuild with one line of code... what's not to like?Uncircumcised
S
3

To disable complete module, try to have the following code in your .htaccess file

<IfModule pagespeed_module>
ModPagespeed off
</IfModule>
Subassembly answered 29/9, 2016 at 20:18 Comment(0)
S
1

To make mod_pagespeed reflect changes to assets immediately, you can configure LoadFromFile: https://developers.google.com/speed/pagespeed/module/domains#ModPagespeedLoadFromFile

This will not work for css/js/images served from virtual handlers, but any changes to static content will be re-optimized immediately. In addition to that, optimization itself will usually be finished a lot faster because loading assets from disk is cheaper then fetching them from http(s).

Swec answered 17/5, 2015 at 20:29 Comment(0)
K
0

Another thing you can do is leave *mod_pagespeed* out of your ssl.conf file. This way, you can access your site via https for development.

Kind of a hack, I know, but it's handy in some cases where you need to make very quick changes.

Kristinkristina answered 23/8, 2013 at 22:26 Comment(0)
V
0

GoDaddy Cloud Bitnami Config

/stack/apache2/conf/nano pagespeed.conf

Turn Off

Veneer answered 31/1, 2017 at 0:44 Comment(0)
A
0

If you're using a W3C Total Cache plugin on WordPress you can try that to deactivate and view the file via inspect mode and always clear cache for the changes.

Abijah answered 13/7, 2017 at 5:44 Comment(0)
U
0

Just as an aside, on this old post, I wrote a PHP script to delete the contents of the pagespeed cache folders (which I placed within the var/www/html area) and added a button to the Magento admin cache control page to call it. This way, whenever the Magento cache needs clearing I can also hit the button to clear the pagespeed cache. The script can be IP and admin restricted. This saves a lot of messing about. You could use a recursive delete folder function like this (careful with your paths!! :) ):

function fullDeleteFolder($dir) { 
  echo "Remove: ".$dir."<br>";
    if (is_dir($dir)) { 
        $objects = scandir($dir); 
        foreach ($objects as $object) { 
            if ($object != "." && $object != "..") { 
                if (is_dir($dir."/".$object)){
                    fullDeleteFolder($dir."/".$object);
                }else{
                    unlink($dir."/".$object); 
                }
            }
            }           
        rmdir($dir); 
    }
}

$location = "[some-location]/mpcache/mod_pagespeed";    
fullDeleteFolder($location);
//might also want to do this for the 'media/css_secure' folder too, if your site is on https
echo "Finished.";
Unbecoming answered 27/7, 2017 at 10:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.