SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: caching headers

  1. #1
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    St Petersburg, Russia
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    caching headers

    Can I use the headers:

    PHP Code:
      header('Cache-control: private must-revalidate');
      
    header('Pragma: cache'); 
    to ensure that my dynamic page is reloaded whenever it has changed, however the browser use its cache if it did not changed. Is it enough? Also with sessions?

  2. #2
    SitePoint Guru enygmadae's Avatar
    Join Date
    Sep 2002
    Location
    Dallas, Tx.
    Posts
    795
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you mean:

    PHP Code:
      header('Cache-control: private must-revalidate'); 
     
    header('Pragma: no-cache'); 
    and maybe throw in a:
    PHP Code:
     header("Expires: " gmdate("D, d M Y H:i:s") . " GMT"); 
    to set it to expire right then...
    PHP News, Views and Community: http://www.phpdeveloper.org

  3. #3
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    St Petersburg, Russia
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    header('Pragma: no-cache') is meant to prevent caching - right? No I want the pages to be cached. I only want the browser to check that last modified time of the page on server is not greater than the last modified time of the page stored by the browser. If it is so then the browser should use the cached page. Otherwise it should load the page from server. As I understand must-revalidate should work this way. But I still want the page to be cached.

  4. #4
    SitePoint Evangelist nsj's Avatar
    Join Date
    Oct 2005
    Location
    Jamaica (W.I)
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thought that caching it would be the done by default. That's why users explicitly set no-cache parameters.

  5. #5
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    St Petersburg, Russia
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nsj
    I thought that caching it would be the done by default. That's why users explicitly set no-cache parameters.
    There so many different browsers, proxies, etc etc etc that I suspect you cant rely on ony defaults

    By the way, IE (some versions at least) does not cache form data like other browsers. So if you dont send cache parameter and the user wants to return to the form and edit it then with IE he will find just empty form and will have to reenter everything again (instead of editing).


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
  •