I am trying to get caching control set up, but I am very confused because several sources are saying to check $_SERVER['HTTP_IF_MODIFIED_SINCE'], but I can't find anything about it on php.net...

To test, I am trying to echo the variable, but it does not display a value. I know that my machine is sending the If-modified-since header.

I am running Apache 2.2.4, PHP 5.2.4 on Windows XP SP2

    Alright... I'm guessing no one has heard of it then...

    Does anyone know how I would access that information though??

      I don't believe it's a PHP Server variable (directly anyway). I believe it's an apache variable that you can retrieve with PHP.

      You can have all kinds of apache/server variables set, with say a rewrite rule, then you can access them with $_SERVER.

        $SERVER['HTTP_IF_MODIFIED_SINCE'] will exist if the client sent a If-Modified-Since header to the server. Otherwise $SERVER will have no mention of it.

        Check for its existence with a isset() before trying to do anything with it.

          Thanks for the replies...

          stolzyboy wrote:

          I don't believe it's a PHP Server variable (directly anyway). I believe it's an apache variable that you can retrieve with PHP.

          You can have all kinds of apache/server variables set, with say a rewrite rule, then you can access them with $_SERVER.

          Can you expand on how I would actually do that?

          landstander wrote:

          $SERVER['HTTP_IF_MODIFIED_SINCE'] will exist if the client sent a If-Modified-Since header to the server. Otherwise $SERVER will have no mention of it.

          Check for its existence with a isset() before trying to do anything with it.

          That is the weird thing... I KNOW the browser is sending it (I am using the Live HTTP headers extension for Firefox. I've tried just checking with isset, and still no luck. I've tried on my own machine and on 1and1.com's server. I've tried IE and Firefox and had someone on another machine test it too. I don't get it.

          edit:

          So funny... a search for $_SERVER['HTTP_IF_MODIFIED_SINCE'] returns this thread as the top result. Where on earth is the documentation for this thing?

            finally figure it out... I have to use getenv("HTTP_IF_MODIFIED_SINCE").. but why?

            EDIT: it's because I have register_globals off! weeeeee! its so nice that I'll finally be able to sleep tonight!

              Strange, I have register_globals off on all my servers and the value is present when it is passed in. Are you using FastCGI or something other than php as a apache module?

                Write a Reply...