Welcome to WebmasterWorld Guest from 184.73.8.127

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

mod expires vs mod headers?

   
2:37 pm on Nov 12, 2012 (gmt 0)

5+ Year Member



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>
2:55 pm on Nov 12, 2012 (gmt 0)

5+ Year Member



...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>
11:15 pm on Nov 12, 2012 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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]
1:15 pm on Nov 13, 2012 (gmt 0)

5+ Year Member



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>
1:38 pm on Nov 13, 2012 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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.
2:15 pm on Nov 13, 2012 (gmt 0)

5+ Year Member



Because thats what almost every tut says to do. infact google says it to. So setting no etag makes google think no new content?