Leverage Browser Caching showing only 5 Minute cache time issue

The reason for Leverage Browser Caching showing only 5 Minute cache time issue could be due to the fact that you are using Mod_Pagespeed module.

A little background: mod_pagespeed extends the cache lifetime of resources and adds a unique hash code to the resource name to improve user cacheability and thus speed up the page load for returning users.

As you’ve pointed out there are two distinct cache lifetimes that are important to mod_pagespeed.

(T.1) is the cache lifetime mod_pagespeed sets. It is currently set to 1 year and I don’t think it is customizable. But since we add in the unique hash code to the URL, you should not need to customize this in most cases. As soon as mod_pagespeed realizes that the resource has changed, it will put a different URL into the HTML file and thus update the user caches.

(T.2) is the original cache lifetime of the resource (by default 5 minutes). mod_pagespeed reloads the file whenever it expires, and thus you see that 3-4 minute lag. There are a couple different ways you can improve this. The best is if the files are completely static, you can use ModPagespeedLoadFromFile. When you use that directive, mod_pagespeed will check the file every time it rewrites HTML, meaning the resource will be updated instantly. If you cannot use LoadFromFile, you can explicitly set shorter cache lifetimes for your resources in Apache. For example:

<Directory ".../foo/">
  ExpiresByType image/gif "modification plus 3 minutes"
  ExpiresByType text/css  "modification plus 1 minute"
<Directory ".../bar/">
  ExpiresByType text/css "modification plus 5 minutes"

However, note that if you reduce this time, you will make mod_pagespeed request the resource more often (every 1 minute for CSS files in foo/ directory above) and can put more load on your server unnecessarily. Another solution is to clear mod_pagespeed cache during development. This can allow you to update the server quickly when developing, but not make your server unnecessarily burdened the rest of the time.

“If you want to modify the default cache time, you can do so with the following directive:

pagespeed ImplicitCacheTtlMs 2629746000;

The time is set in milliseconds. Those directives should be set in the “Advanced” settings for the domain you want to change it to.”


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s