Welcome to WebmasterWorld Guest from 18.104.22.168 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Pubcon Platinum Sponsor 2014
mod expires vs mod headers? ewwatson msg:4518341 2:37 pm on Nov 12, 2012 (gmt 0) Ok I got them both working. Now which one is better? Are there any differences as to how each browser reads and implements them? thanks! Here is my code for each... # Cache Files ExpiresActive On ExpiresDefault "access plus 1 year" ExpiresByType text/html "access plus 1 day" ExpiresByType text/css "access plus 1 day" # 1 Year <filesMatch "\.(jpg|jpeg|png|gif|swf|js)$"> Header set Cache-Control "max-age=29030400, public" </filesMatch>
ewwatson msg:4518347 2:55 pm on Nov 12, 2012 (gmt 0)
...also. Is Header set Expires "Tue, 16 Jun 2020 20:00:00 GMT" and Header set Cache-Control "max-age=29030400, public" do the exact same thing. Just a different way of saying it? so.. <FilesMatch ".(ico|jpg|jpeg|png|gif|js|css|swf)$"> Header set Expires "Tue, 16 Jun 2020 20:00:00 GMT" </FilesMatch> vs # Cache Files 1 Year <filesMatch "\.(jpg|jpeg|png|gif|swf|js)$"> Header set Cache-Control "max-age=29030400, public" </filesMatch> phranque msg:4518499 11:15 pm on Nov 12, 2012 (gmt 0)
the first is "better" because using mod_expire handles both the Cache-Control and Expires headers for you. a Cache-Control header with the max-age directive overrides an Expires header but you need the Expires header for those HTTP/1.0 caches which don't implement Cache-Control. you might want to study the example provided by jdmorgan here. Configuring Expires and Cache-Control response headers: http://www.webmasterworld.com/apache/4044285.htm?highlight=msg4044403 [ webmasterworld.com] ewwatson msg:4518723 1:15 pm on Nov 13, 2012 (gmt 0)
OK here is what I ended up with. After reading for weeks on this I think this is the best setup. The only thing it seems I went out on a limb on is caching html for a long time. I toyed with this in my brain. Many say cache css for a long time. Well I can't cache css, or js for that matter, without caching the html. When ever I edit one 9 times out of 10 I'm editing one of the others. Well if one is a new copy and one isn't the user will very likely see something wonky or unstyled, or un-js'ed. My question is this? Am I missing something about caching the html? Or is the only downside the user waits 90 days to see the updated copy? Additionally Google always sees the newset copy correct? Thanks for your knowledge! # Compress Files <FilesMatch "\.(js|css|html|php|xml)$"> SetOutputFilter DEFLATE </FilesMatch> # Turn off the ETags Header unset ETag FileETag None # Cache Files 90 Days <filesMatch "\.(html|css|js|swf|pdf|xml|mp3|gif|jpg|png)$"> ExpiresActive On ExpiresDefault "access plus 90 days" Header append Cache-Control "public" </filesMatch> phranque msg:4518727 1:38 pm on Nov 13, 2012 (gmt 0)
why turn off Etags? expiration should be based on a reasonable guess of how often the resource will change. google sends an If-Modified-Since header (and an Etag header if available) with subsequent requests, and looks for a 304 Not Modified response. ewwatson msg:4518729 2:15 pm on Nov 13, 2012 (gmt 0)
Because thats what almost every tut says to do. infact google says it to. So setting no etag makes google think no new content?