Short answer, please try
ModPagespeedLoadFromFile. If you are able to use this feature to read resources directly from the file system into mod_pagespeed then you will not see this behavior.
This occurs on low-traffic server due to your origin resources expiring on mod_pagespeed's server. For example, http://twitterbogen.dk/css/blueprint/screen.css has these response-headers:
Date: Tue, 19 Jun 2012 11:16:02 GMT
Last-Modified: Sat, 16 Jun 2012 23:51:48 GMT
Etag: "23de7-3034-4c29f9db1efb5"
As there are no caching headers, mod_pagespeed interprets this to mean "cache on the server for 5 minutes". In a debug server, for example, the only one making queries is you. If you don't do a query for more than 5 minutes, then the next time you do one, mod_pagespeed must consider all the resources to be expired, and fetch them again to see if they've changed. This strategy allows mod_pagespeed to react to changes in your source files, but still serve pre-optimized content to your users.
If you are getting a query per minute, this is usually no problem, as after 4 minutes, mod_pagespeed will still consider screen.css to be valid in its cache, but will also notice that it's 80% expired and will "freshen" it by fetching it again from origin. So severs in production usually don't serve unoptimized content.
ModPagespeedLoadFromFile bypasses this issue because on every request, mod_pagespeed can check whether the file is updated by looking at its timestamp directly in the file system.
If you can't use ModPagespeedLoadFromFile you can also set the origin TTL of your resources to be longer. To set it to 10 minutes use:
<FilesMatch "\.(jpg|jpeg|gif|png|js|css)$">
Header set Cache-control "max-age=600"
</FilesMatch>
Hope this helps,
-Josh
On Tue, Jun 19, 2012 at 3:16 AM, Jacob Friis Saxberg
<jacob....@gmail.com> wrote:
I've setup mod_pagespeed and it seems to work fine, but only when I reload a page. Minutes later the optimization is gone.
Here's a static site where full optimization is only done when you reload the page:
On the first load the CSS files have no .pagespeed. in them. If you reload they do.
Any idea why?
And here's my mod_pagespeed configuration:
ModPagespeed on
AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html
ModPagespeedFileCachePath "/var/www/mod_pagespeed/cache/"
ModPagespeedGeneratedFilePrefix "/var/www/mod_pagespeed/files/"
ModPagespeedEnableFilters rewrite_javascript,rewrite_css
ModPagespeedEnableFilters collapse_whitespace,elide_attributes
ModPagespeedEnableFilters extend_cache,combine_css,move_css_above_scripts,move_css_to_head,inline_css,inline_import_to_link,flatten_css_imports,inline_javascript,outline_javascript,rewrite_style_attributes,rewrite_images,sprite_images
ModPagespeedAvoidRenamingIntrospectiveJavascript on
ModPagespeedMessageBufferSize 100000