Forum Moderators: phranque

Message Too Old, No Replies

help with expires and deflate

         

mihomes

5:07 pm on May 3, 2011 (gmt 0)

10+ Year Member



Wondering if I could get some input on this... let me also say that all html, htm, php pages are already sending correct headers through a content negotiation script I am using (conteg) by Alex so I'm really only concerned about everything else right now.


# BEGIN expires rules
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpeg "access plus 1 months"
ExpiresByType image/jpg "access plus 1 months"
ExpiresByType image/gif "access plus 1 months"
ExpiresByType image/png "access plus 1 months"
ExpiresByType text/css "access plus 10 days"
ExpiresByType application/javascript "access plus 10 days"
ExpiresByType image/ico "access plus 1 months"
ExpiresByType image/x-icon "access plus 1 months"
ExpiresByType text/plain "access plus 1 months"
ExpiresByType application/pdf "access plus 1 months"
ExpiresByType application/x-shockwave-flash "access plus 1 months"
ExpiresDefault "access plus 2 days"
</IfModule>
# END expires rules
# BEGIN Compress files
<ifModule mod_deflate.c>
<filesMatch "\.(js|css|rss|xml)$">
SetOutputFilter DEFLATE
Header append Vary Accept-Encoding
</filesMatch>
</ifModule>
# END Compress files


- is it okay to use the bytype method? Is there a benefit to the other way :

<filesMatch "\.(jp[b]e?g[/b]|gif|png|css|js|ico|pdf|swf|flv)$">
ExpiresDefault "access plus 15 days"
</filesMatch>
ExpiresDefault "access plus 2 days"


- regarding above would ico still satisfy the sites favicon?

- is there any other formats you would recommend adding?

- I see a lot of people use cache-control rather than expires... since I am using 'access plus' isn't this essentially the same thing? What about public/private and why would I need to add or not?

Appreciate it guys... I can make a website, but stuff like this is somewhat new to me, but I am here to learn from the best so any help be great!

mihomes

6:31 pm on May 5, 2011 (gmt 0)

10+ Year Member



Anyone?

mihomes

7:29 pm on May 6, 2011 (gmt 0)

10+ Year Member



Well this is what I came up with :

# BEGIN expires rules
<IfModule mod_expires.c>
ExpiresActive on
<FilesMatch "\.(jpe?g|gif|png|ico|pdf|swf|flv)$">
ExpiresDefault "access plus 20 days"
</FilesMatch>
<FilesMatch "\.(js|css)$">
ExpiresDefault "access plus 10 days"
</FilesMatch>
ExpiresDefault "access plus 2 days"
</IfModule>
# END expires rules
# BEGIN compress files
<IfModule mod_deflate.c>
<FilesMatch "\.(js|css|rss|xml)$">
SetOutputFilter DEFLATE
Header append Vary Accept-Encoding
</FilesMatch>
</IfModule>
# END compress files

Using live headers in ff here is an example response :

HTTP/1.1 200 OK
Date: Fri, 06 May 2011 19:21:47 GMT
Server: Apache
Last-Modified: Thu, 05 May 2011 19:23:50 GMT
Accept-Ranges: bytes
Content-Length: 646
Cache-Control: max-age=1728000
Expires: Thu, 26 May 2011 19:21:47 GMT
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: image/jpeg

I'm curious to know why max-age has been defined here eventhough I do not set it... does it simply use the values given to my expires as they match up?

Second, I see some people recommending a cache-control public, other do not, then more have additional added. Could some one more knowledgable chime in? It is my understanding that if I added cache-control public for images changes would still be checked due to my last modified... so say I wouldn't necessarily need to change filenames when I modify an image.

Other than that would anyone recommend any other changes?