#1  
Old 29th December 2010, 04:39
entertheraptor entertheraptor is offline
Member
 
Join Date: Dec 2010
Location: Melbourne, Australia
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to entertheraptor
Default (SOLVED) Cache Control

Here's the deal, I make modifications to pages on my server and then go to my site and the mods aren't visible. So I refresh the page and there they are.

I'm figuring this is because my browser is caching the pages and recalling them from the cache rather than loading them fresh from the server.

This is no good to me as the content on my pages will be changing frequently so I need browsers to not cache my pages.

I tried the META CACHE-CONTROL tag but it didn't work in any of three browsers (IE, Firefox and Chrome) and a little reading tells me that the best way to deal with this issue is server side.

I'm running Ubuntu 10.10 installed as per the "Perfect Server - Ubuntu 10.10 [ISPConfig 3]" guide. How do I activate and configure mod_cache and mod_expires? (or should I?)

Advice on how to best handle this please. (with detailed instructions for dummies would be nice)

Last edited by entertheraptor; 30th December 2010 at 21:31. Reason: falko fixed it :)
Reply With Quote
Sponsored Links
  #2  
Old 29th December 2010, 15:51
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,740 Times in 2,575 Posts
Default

You can use PHP to set headers that disable caching, e.g. like this:
PHP Code:
<?php
header
("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 30th December 2010, 02:07
entertheraptor entertheraptor is offline
Member
 
Join Date: Dec 2010
Location: Melbourne, Australia
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to entertheraptor
Default

Wow, all the reading I did and NO ONE anywhere talked about or suggested this method. It's all about META tags that don't work or controlling cache with server configuration.

This is so simple and perfect, thanks falko you're a legend. How would you like to have a crack at my thread about getting a error 500 when I try to access Roundcube using mydomain.com/mailbox

Just quickly, I assume that this code goes in the <HEAD> section of your php page. Is this correct?

Oh, and where the above code sets the expiration date, can I use -1 rather than a date?

Last edited by entertheraptor; 30th December 2010 at 02:09.
Reply With Quote
  #4  
Old 30th December 2010, 17:43
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,740 Times in 2,575 Posts
Default

Quote:
Originally Posted by entertheraptor View Post
Just quickly, I assume that this code goes in the <HEAD> section of your php page. Is this correct?
This goes before anything else - there must not be any output (not even the <head> section or the document type definition) before these lines.

Quote:
Originally Posted by entertheraptor View Post
Oh, and where the above code sets the expiration date, can I use -1 rather than a date?
Haven't tried that, but you can simply use the date I posted because it's in the past.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #5  
Old 30th December 2010, 21:28
entertheraptor entertheraptor is offline
Member
 
Join Date: Dec 2010
Location: Melbourne, Australia
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to entertheraptor
Default

Yep, got it now. Great work falko, thanks heaps
Reply With Quote
Reply

Bookmarks

Tags
cache, cache control, expires

Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
My Centos is terribly slow Galled Server Operation 9 7th December 2010 15:31
Adaptec 2405 + ISP Config 3.0.3 terekhov Developers' Forum 4 3rd November 2010 14:04
Unable to connect to Mysql mbascombe Installation/Configuration 12 10th January 2010 22:46
Squid Proxy Caching on Linux obzerver Installation/Configuration 4 13th August 2008 19:51
Webmin docs missing namit Server Operation 11 5th January 2006 09:51


All times are GMT +2. The time now is 21:18.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.