SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict IsaacV's Avatar
    Join Date
    Jan 2002
    Location
    Saint Petersburg
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Preventing a page from being cached in history

    Hi.
    I used .htaccess to create my own custom error page, error.php. It adds page requests that generate errors to a database table or, if the correct page is in the database, redirects the visitor to the correct page with a witty remark. What I've found is that when the user starts clicking back, it relogs the error.

    How do I keep a page from being cached in browser history so that when you click back, it goes to the page before you went to the error page instead of the error page?
    Pants.
    Join the NYFlava Fashions Contest

  2. #2
    Forum Mathematics Geek Agent Dwarf's Avatar
    Join Date
    Aug 2002
    Location
    Commonwealth of Pennsylvania
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think it's (remember, I *think*):

    PHP Code:
    header("Cache: no-cache"); 

  3. #3
    SitePoint Addict IsaacV's Avatar
    Join Date
    Jan 2002
    Location
    Saint Petersburg
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Agent Dwarf
    I think it's (remember, I *think*):

    PHP Code:
    header("Cache: no-cache"); 
    No. That prevents the page from being cached, doesn't keep it out of history.
    Pants.
    Join the NYFlava Fashions Contest

  4. #4
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To support different standards and clients you will need a bit more than that:

    PHP Code:
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0"false);
    header("Pragma: no-cache"); 
    http://www.php.net/manual/en/function.header.php

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  5. #5
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hang on - do you mean stop the browser displaying the name of the error page?

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  6. #6
    SitePoint Addict IsaacV's Avatar
    Join Date
    Jan 2002
    Location
    Saint Petersburg
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It doesn't prevent it from being cached in history.

    Anyone else with any ideas?
    Pants.
    Join the NYFlava Fashions Contest

  7. #7
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The history is client side and there are no standards for stopping a page appear in the browser history, so you are very unlikely to be able to do it.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  8. #8
    SitePoint Wizard Mincer's Avatar
    Join Date
    Mar 2001
    Location
    London | UK
    Posts
    1,140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this for one page or for all pages?

    If it's just for one link you could make the link from a form that submits a hidden field via post. In the new apge, set a session/cookie var that says the page has been viewed. When the browser goes back you'll get an error that the page has expired. If the user re-submits the form you can check if the data is in the session/cookie and if it is....exit();

    Obviously this isn't really an option for lots of pages, but for one it might work.

    Matt.


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
  •