I was considering making some of these changes to my htaccess file for my Wordpress installation and figured I ought to run it by you guys first...
According to the article, you can "Dramatically Speed up your site by implementing Caching!" The author provides the following code but doesn't explain what it means in english:
CODE
# MONTH
<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
# WEEK
<FilesMatch "\.(js|css|pdf|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
# DAY
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>
Prevent Files image/file hotlinking and bandwidth stealing
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?askapache.com/.*$ [NC]
RewriteRule \.(gif|jpg|swf|flv|png)$ http://www.askapache.com/legal.gif [R=302,L]
<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
# WEEK
<FilesMatch "\.(js|css|pdf|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
# DAY
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>
Prevent Files image/file hotlinking and bandwidth stealing
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?askapache.com/.*$ [NC]
RewriteRule \.(gif|jpg|swf|flv|png)$ http://www.askapache.com/legal.gif [R=302,L]
- Am I to understand that this basically caches image files for a month, JS/CSS for a week and html for a day?
- If so how does this affect the fact that Wordpress is entirely PHP driven? In other words, if I make changes to my PHP (which I do all the time) would it prevent me from seeing the changes immediately?
- My site has more MB of images than RAM so what happens if the server runs out of RAM (it's Linux)?
- What would happen if I were to theoretically change my CSS or something that was cached. Would the system know that and re-cache it or would you have to manually clear the cache somehow?
They also say you can "Prevent Files image/file hotlinking and bandwidth stealing" with the following:
CODE
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?askapache.com/.*$ [NC]
RewriteRule \.(gif|jpg|swf|flv|png)$ http://www.askapache.com/legal.gif [R=302,L]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?askapache.com/.*$ [NC]
RewriteRule \.(gif|jpg|swf|flv|png)$ http://www.askapache.com/legal.gif [R=302,L]
Is there any reason NOT do do this?
Finally, what's the ServerSignature and why would you want to turn it off?
Thanks,
John