Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
Help with .htaccess cache control
Old 03-27-2010, 07:36 PM Help with .htaccess cache control
Novice Talker

Posts: 13
Name: Layla Stone
Location: California
Trades: 0
I have a website which gets updated sporadically, but most of the time when I go online to check the updates, it shows me a old cached version. I have been trying forever to figure out how to control caching successfully without luck until today. I finally found articles on how to control caching via the .htaccess file in my server directory. I want all of my background images and such to cache for three months and all of my text and such to cache for one week. But I also want it to check to make sure that there haven't been any modifications even before those time periods are up, and to update the page as necessary if there have been.

After wading my way through many pages on the topic, I have patched together some possible code and I would like any feedback on whether this code will do what I described above.



# cache images for 3 month
<FilesMatch ".(gif|jpg|jpeg|png|flv|swf|ico)$">
Header set Cache-Control "max-age=7257600, must-revalidate"
</FilesMatch>

# cache everything else for 1 week
<FilesMatch ".(js|css|pdf|txt|html|htm)$">
Header set Cache-Control "max-age=604800, must-revalidate"
</FilesMatch>

# disable caching for dynamic files
<FilesMatch ".(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control
</FilesMatch>



Thank you for any feedback, Layla
layla9 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-27-2010, 08:07 PM Re: Help with .htaccess cache control
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,390
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Just press Ctrl+F5 when you are looking at the pages.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-27-2010, 08:27 PM Re: Help with .htaccess cache control
Novice Talker

Posts: 13
Name: Layla Stone
Location: California
Trades: 0
Quote:
Just press Ctrl+F5 when you are looking at the pages.
and that does what exactly?

And I do this when looking at the webpages I want to cache control?

Is this a Mac or windows hotkey?

Last edited by layla9; 03-27-2010 at 08:30 PM..
layla9 is offline
Reply With Quote
View Public Profile
 
Old 03-27-2010, 08:32 PM Re: Help with .htaccess cache control
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,390
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Windows and it does a "Forced refresh" of the browser cache.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-27-2010, 08:43 PM Re: Help with .htaccess cache control
Novice Talker

Posts: 13
Name: Layla Stone
Location: California
Trades: 0
I have a mac. Is the hotkey the same?

Secondly, I don't want something that the user will have to do. I want to know that someone else on their own computer will not be seeing a stale page, but also won't have to download the background images and such from scratch each time they view the page.
layla9 is offline
Reply With Quote
View Public Profile
 
Old 04-01-2010, 04:10 PM Re: Help with .htaccess cache control
Novice Talker

Posts: 13
Name: Layla Stone
Location: California
Trades: 0
Today I made small changes on three different pages, and two of them refreshed and one didn't. Why didn't the code work? What could I change to make it force a refresh when there have been changes, but allow it to use the cache if there haven't been changes?
layla9 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help with .htaccess cache control
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25859 seconds with 12 queries