SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2001
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    avoid caching of dynamic pages

    I've discoverd that the site I'm working on, sometimes gets cached in my browser. And I dont want that, cause its a dynamic site and the indexpage with an overview of the recent content changes about every 10 minutes (whenever someone submits some new input) . What I see then is a page from some hours back, and only after refreshing a few times I see the new page. Also I tend to logged out of my user sessions when the caching happens.

    I had a similar problem before with images. When a new one from the same user was submitted, you would still see the old one. But I solved it by adding the unixtime value to every new imagename, so that it was new and unique and would not be taken from the cache.

    So, is there a way I can prevent the caching of my dynamic pages ?

    (yes, I searched the forum for this, but couldnt find a solution)

  2. #2
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One thing you can do is

    Code:
    <meta http-equiv="Pragma" CONTENT="no-cache">
    in your HTML. If it's server-side caching then there are ways to stop that too. I'm an ASP programmer though, and the ASP code is no use to you!

  3. #3
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,609
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Not sure if it will work with PHP (though I don't see why not), but you could append a querystring to the URL which has a value of the unix time (like you did with images). This should make each and every page unique and hence not cached.

    Whether this is viable at the current stage of development of your site is another question though.
    Ian Anderson
    www.siteguru.co.uk

  4. #4
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There shouldn't be any need for that -- there's bound to be a PHP command to stop caching if you look. I know there's one for ASP so there's bound to be an equivalent!

    G

  5. #5
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,609
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You talking about Response.Expires? If so then I'm sorry to pull the rug from under you but it is not guaranteed to work. IE browsers always cache pages, no matter what you do to try and stop it. (Those MS people are sooo helpful, aren't they. )
    Ian Anderson
    www.siteguru.co.uk

  6. #6
    SitePoint Zealot
    Join Date
    Dec 2001
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    - I've added the meta tag, and I think it sure can help
    - adding the unixtime to the php file is not really possible , cause its also about the index.php page here.
    - and yep, its a client thing.. Only a few of my testers reported it, and I didnt had that problem for a week. And when I had some problem with my browser and had to reset the options, I suddenly encountered this problem too although the phpcode hadnt changed.

    Anyway, thnx for that meta tag tip, I'll see and wait whether it works


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •