homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

doubts about my caching in htaccess

 9:08 pm on May 9, 2012 (gmt 0)

Having some doubts about my caching method per my htaccess file I made up some time ago.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.widget\.com)?$
RewriteRule (.*) http://www.widget.com/$1 [R=301,L]
# BEGIN defaults
DefaultLanguage en
AddDefaultCharset utf-8
AddType 'text/css; charset=utf-8' css
AddType 'application/javascript; charset=utf-8' js
# END defaults
# BEGIN expires rules
<IfModule mod_expires.c>
ExpiresActive on
<FilesMatch "\.(jpe?g|gif|png|ico|pdf|swf|flv)$">
ExpiresDefault "access plus 20 days"
Header append Cache-Control "public"
<FilesMatch "\.(js|css|txt)$">
ExpiresDefault "access plus 10 days"
Header append Cache-Control "private, must-revalidate"
<FilesMatch "\.(html?|php)$">
ExpiresDefault "access plus 2 days"
Header append Cache-Control "private, must-revalidate"
ExpiresDefault "access plus 1 hours"
# END expires rules
# BEGIN compress files
<IfModule mod_deflate.c>
<FilesMatch "\.(html?|php|js|css|rss|xml)$">
SetOutputFilter DEFLATE
# END compress files

Should I be adding 'access plus blah blah' to the cache-control statements as well? My goal was to have both expires and cache-control as recommended by many (a backup if you will).

Am I also correct that if I make a change to a page the last-modifed check will be skipped UNTIL the set time passes and the cached content is considered stale... after this time it will show the new content?

I'm also assuming that 'access plus...' is the first access to the file... so if I set expires to access plus 10 days the visitor could go to the page as many times as he wants but 10 days from his original visit it would check for new content and changes correct?

Sorry for the newb'ish question, but don't deal all too much with this kind of stuff.



 11:22 pm on May 9, 2012 (gmt 0)

For starters: Get rid of the "IfModule" envelope. Not its contents, just the envelope. Replace it with blank lines so you can see what you're doing. Same for all "IfModule" constructions. You either have the module or you don't. (If you don't know, and your host won't tell you, there's a simple test you can run.)


 1:54 am on May 10, 2012 (gmt 0)

You either have the module or you don't.

No kidding lol. I prefer to keep it this way as its just how I like to write code.

As for the questions... I'm pretty sure I found my own answer as I brushed myself up this afternoon. Everything appears to be intact correctly... and I am still using expires and have it turned on (double checked the server settings to be sure).

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved