Cache Control

Discussion in 'Server Operation' started by entertheraptor, Dec 29, 2010.

  1. entertheraptor

    entertheraptor New Member

    (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: Dec 30, 2010
  2. falko

    falko Super Moderator ISPConfig Developer

    You can use PHP to set headers that disable caching, e.g. like this:
    ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  3. entertheraptor

    entertheraptor New Member

    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 :)

    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: Dec 30, 2010
  4. falko

    falko Super Moderator ISPConfig Developer

    This goes before anything else - there must not be any output (not even the <head> section or the document type definition) before these lines.

    Haven't tried that, but you can simply use the date I posted because it's in the past.
  5. entertheraptor

    entertheraptor New Member

    Yep, got it now. Great work falko, thanks heaps :)

Share This Page