4

I have enabled pagespeed module and find that for some resources (image, js and css) that are re-written by pagespeed the cache is set to the default 5 minutes. Few other resources (image, js and css) re-written by pagespeed has Cache-Control: max-age=31536000.

I explicitly give set by ExpiresDefault to 1 year for all my static resources in .htaccess.

The response i get has this:

Cache-Control:max-age=300,private

I am expecting:

Cache-Control:max-age=31536000,private

Suggestions and pointers are appreciated.

Shubham Bhave
  • 383
  • 6
  • 17
user3853029
  • 61
  • 1
  • 3

1 Answers1

1

mod_pagespeed only serves responses with Cache-Control:max-age=300,private if the Hash in the URL doesn't match the content. This can happen normally when A) the contents of the resource changed recently and so there are a mixture of requests for both old and new URLs for some time or B) the rewriting does not finish in time when serving the resource.

This is most likely to happen if the resource request goes to a different server than the HTML request. You can try flushing the cache and see if this clears up.

sligocki
  • 6,246
  • 5
  • 38
  • 47
  • 1
    I noticed a side-effect to pagespeed module - many images, js and css are cached only for 5 minutes. This is because the name of the images, js and css have changed because of re-write and origin does not have files with the re-written name. Is there a way to have pagespeed and also have the cache-control as specified by the origin? – user3853029 Jul 25 '14 at 07:38
  • Your installation is not functioning correctly. Generally if you are using mod_pagespeed, rewritten resources should be served with long (one year) cache lifetimes. This is a feature of mod_pagespeed! But on your server something is wrong. I described the problem in my answer. Did you try flushing the cache? You can also contact us at our discussion list for more interactive feedback: https://groups.google.com/forum/#!forum/mod-pagespeed-discuss – sligocki Jul 25 '14 at 15:26