WebPagetest Forums
negative scoring for wrong cache headers - Printable Version

+- WebPagetest Forums (https://www.webpagetest.org/forums)
+-- Forum: WebPagetest (/forumdisplay.php?fid=7)
+--- Forum: Feature Suggestions (/forumdisplay.php?fid=9)
+--- Thread: negative scoring for wrong cache headers (/showthread.php?tid=755)



negative scoring for wrong cache headers - sajal - 05-16-2011 05:07 PM

Ive come across a site whose doing this in .htaccess

Code:
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4)$">
Header set Cache-Control "public"
Header set Expires "Thu, 15 Nov 2010 20:00:00 GMT"
Header unset Last-Modified
</FilesMatch>
#2 hours
<FilesMatch "\.(html|htm|xml|txt|xsl)$">
Header set Cache-Control "max-age=7200, must-revalidate"
</FilesMatch>
<FilesMatch "\.(js|css)$">
SetOutputFilter DEFLATE
Header set Expires "Thu, 15 Nov 2010 20:00:00 GMT"
</FilesMatch>

Why would anyone do that is beyond me. but... webpagetest.org gives this site an A in caching... In the same time the repeat view does a if-modified-since request for this.

Would have been easier to spot this mixup if WPT gave negative scoring for such things... small cache durations already result in a warning... negative duration should be an err

-Sajal


RE: negative scoring for wrong cache headers - pmeenan - 05-17-2011 02:12 AM

Thanks. The code right now favors a cache-control header and if one is present it will calculate a duration based on the time set. For expires headers it just checks for the presence and doesn't actually check the date (been a TODO for a while). If it's not too hard to parse the dates in c++ I'll see if I can get it added quickly, otherwise I'll make sure it's correct as we move individual rules to use Page Speed's logic.