Thursday, 15 August 2013

apache - mod_pagespeed is not sending expected output with extended cache -


For testing purposes, I have this Apache configuration:

  & lt; Directory "/ home / http" & gt; ... & lt; File match ". (Html ​​| htm) $" & gt; Header set the header header set-up cache-control "max-age = 0, no-cache" & lt; / FilesMatch & gt; & Lt; File match ". (Jpg | jpeg | gif | png | js | css) $" & gt; Header set the header header set up cache-control "Public, Maximum-age = 10" & lt; / FilesMatch & gt; & Lt; / Directory & gt;   

It basically asks for setting static assets which stays up to 10 seconds for the cache, then for this test and display purposes

I Navigate directly to this file and test it out

  $ wget -O -. --save-header local host / mod_pagespeed_example / images / puzzle Jpg cache-control: public, max-age = 10   

Which works fine? But then I try to load the page with mod_pagespeed and extend_cache enabled

  $ wget -O - --save-header local host / mod_pagespeed_example / extend_cache.html ModPagespeed = on & amp; ModPagespeedFilters = extend_cache & lt; IMG src = "picture / puzzle.jpg" /> $ Wget -O - --save-header local host / mod_pagespeed_example / extend_cache.html ModPagespeed = ON & amp; ModPagespeedFilters = extend_cache & lt; Img src = "http: //localhost/mod_pagespeed_example/images/xPuzzle.jpg.pagespeed.ic.hgbHsZe0IN .jpg" />   

It's all right and dandy. The initial request does not work because it needs to load the information in the cache, but from there it is cached correctly, the src of the img tag changes with the broken version.

However, it only prevails until the maximum age. So, if I set it to 10 seconds, it will continue to point to http: //localhost/mod_pagespeed_example/images/xPuzzle.jpg.pagespeed.ic.hgbHsZe0IN.jpg , but Then go back to anywhere on Picture / Puzzle.jpg after 10 seconds, at that time it will be back in the cached version.

Is this the expected behavior? I would think that PageSpeed ​​will check the hash after the maximum age, and if it is the same, it is not bothered to change it back to the actual value, but instead the service of the cached file continues.

It's about to a certain extent. If I have set the maximum age to be more useful, then say that 60 minutes, which allows me to update these asset files and assures that my updates are viewed on time. However, if users visit the site once per day, then they are more than the maximum age and they always serve the original file instead of the cached version.

This is expected behavior as you mention, the reason is that the resource ends in the cache And we will have to re-examine it to ensure that it is still the same. We do not want to block the user request when we check all the sub-resources.

Note, one solution would be to use it. It will check the last modified time of the file on the disk and can also check if the resource cache is finished.

No comments:

Post a Comment