header("Cache-Control: public") not working

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    header("Cache-Control: public") not working

    I have read somewhere else in this newsgroup that the way to avoid the
    message (Warning: Page has Expired blah, blah blah ... ) when one
    presses the back button is to place the statement
    header("Cache-Control: public");
    at the top of the script.
    I have done this but I still get the annoying message.
    The session.cache_e xpire in php.ini is set to 180. I am using shared
    SSL.
    Thank you for you help

    John
  • R. Rajesh Jeba Anbiah

    #2
    Re: header("Ca che-Control: public") not working

    johnmark@faster mail.com (John) wrote in message news:<1ab390bb. 0408021025.70f9 39cf@posting.go ogle.com>...[color=blue]
    > I have read somewhere else in this newsgroup that the way to avoid the
    > message (Warning: Page has Expired blah, blah blah ... ) when one
    > presses the back button is to place the statement
    > header("Cache-Control: public");
    > at the top of the script.
    > I have done this but I still get the annoying message.[/color]

    AFAIK, for that you need to use session_cache_l imiter('private ,
    must-revalidate') if you're using session.

    BTW, header("Cache-Control: public") doesn't make any sense at all
    (IMHO) as you have to use client cache. I guess, it might be
    "private".

    --
    | Just another PHP saint |
    Email: rrjanbiah-at-Y!com

    Comment

    • John

      #3
      Re: header(&quot;Ca che-Control: public&quot;) not working

      ng4rrjanbiah@re diffmail.com (R. Rajesh Jeba Anbiah) wrote in message news:<abc4d8b8. 0408022349.6352 382e@posting.go ogle.com>...[color=blue]
      > johnmark@faster mail.com (John) wrote in message news:<1ab390bb. 0408021025.70f9 39cf@posting.go ogle.com>...[color=green]
      > > I have read somewhere else in this newsgroup that the way to avoid the
      > > message (Warning: Page has Expired blah, blah blah ... ) when one
      > > presses the back button is to place the statement
      > > header("Cache-Control: public");
      > > at the top of the script.
      > > I have done this but I still get the annoying message.[/color]
      >
      > AFAIK, for that you need to use session_cache_l imiter('private ,
      > must-revalidate') if you're using session.
      >
      > BTW, header("Cache-Control: public") doesn't make any sense at all
      > (IMHO) as you have to use client cache. I guess, it might be
      > "private".[/color]



      header("Cache-Control: private") does not seem to work either

      John

      Comment

      • R. Rajesh Jeba Anbiah

        #4
        Re: header(&quot;Ca che-Control: public&quot;) not working

        johnmark@faster mail.com (John) wrote in message news:<1ab390bb. 0408031120.694e 179@posting.goo gle.com>...[color=blue][color=green][color=darkred]
        > > > I have read somewhere else in this newsgroup that the way to avoid the
        > > > message (Warning: Page has Expired blah, blah blah ... ) when one
        > > > presses the back button is to place the statement
        > > > header("Cache-Control: public");
        > > > at the top of the script.
        > > > I have done this but I still get the annoying message.[/color]
        > >
        > > AFAIK, for that you need to use session_cache_l imiter('private ,
        > > must-revalidate') if you're using session.
        > >
        > > BTW, header("Cache-Control: public") doesn't make any sense at all
        > > (IMHO) as you have to use client cache. I guess, it might be
        > > "private".[/color]
        >
        > header("Cache-Control: private") does not seem to work either
        >[/color]
        What about session_cache_l imiter('private ,[color=blue]
        > must-revalidate')??[/color]

        --
        | Just another PHP saint |
        Email: rrjanbiah-at-Y!com

        Comment

        • John Wellesz

          #5
          Re: header(&quot;Ca che-Control: public&quot;) not working

          On 02 août 2004, Sir johnmark@faster mail.com (John) claimed in
          news:1ab390bb.0 408021025.70f93 9cf@posting.goo gle.com:
          [color=blue]
          > I have read somewhere else in this newsgroup that the way to avoid the
          > message (Warning: Page has Expired blah, blah blah ... ) when one
          > presses the back button is to place the statement
          > header("Cache-Control: public");
          > at the top of the script.
          > I have done this but I still get the annoying message.
          > The session.cache_e xpire in php.ini is set to 180. I am using shared
          > SSL.
          > Thank you for you help
          >
          > John[/color]


          Well that's not true, you need to tell the browser that it can cache the
          page so, you have to tell him that the page is valid for a certain time,

          the header("Cache-Control: public"); just tell to intermediate proxies
          that they are authorized to record the page in their cache.

          what you need is to send headers like:

          header("Cache-Control: private, max-age=3600");

          ##tell that it can keep the page for 1 hour in his cache (may be enough
          to avoid the "page expire thing")


          header("Expires : Wed, 04 Aug 2004 12:28:41 GMT");
          ##tell that he must check the page validity after this date

          header("Last-Modified: Fri, 16 Jul 2004 22:07:59 GMT");
          ##tell that the page was modified on this date (used by proxies and
          browsers to know if they need to recache the page or not)

          so youre code would be:
          <?php
          $valid_date=360 0;
          $the_time=time( );
          $lastmodifie=fi lemtime(_SERVER["SCRIPT_FILENAM E"]);

          header("Cache-Control: private, max-age=$valid_date ");
          header("Expires : " . gmdate("D, d M Y H:i:s", $the_time + $valid_date) .
          " GMT");
          header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodifie) . "
          GMT");
          ?>


          Comment

          Working...