Re: question on header() function



JRough wrote:
On Nov 10, 8:23 pm, gordonb.a5...@xxxxxxxxxxx (Gordon Burditt) wrote:
What is the purpose of caching in the header below? I used
something like this for downloading a detail page to Excel but in this
example it looks like it is for cache control? Why would you expire a
header? So the user couldn't send a request after too long of a period
for example in the downloaded excel page?
Generally, headers like this encourage a browser to get UP-TO-DATE
dynamic content from the server, as distinguished from old data in
its cache.

<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the
past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// always
modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/
1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
Also, what is the status header for or rather how does it work? You
can get some status information from the server?
Yes. There are several types of errors that can be returned (page
not found, page moved temporarily, page moved permanently, access
denied, page found OK, etc.) Certain status codes encourage the
browser to try again with a different URL, or to ask the user for
authentication information and resubmit the request.

Is this sent in
conjunction with a header request? What is not found the page or the
server?
This header is being sent FROM THE SERVER. Do you think it is
likely that the server will send an error code that the server
wasn't found?

header(“Status: 404 Not Found”);

thanks, so the cache is in the browser page displayed and if the data
changed it would get more recent data than the expired data on the
page unless you wanted the user to download the same data as what he
originally saw on the page. In any case it is the veriation in the
data at that moment in time viewed by the user and some other later
date in case
he leaves his browser open for awhile then decides to download the
data later.

What is the boolean replace function for in the header function?

thanks

No, the cache is in the browser. The page cannot cache itself.

Also, it doesn't matter if the browser is left open or not. Cache can also be stored on disk and used even after you reboot.

As to the replace parameter - from the manual:

"The optional replace parameter indicates whether the header should replace a previous similar header, or add a second header of the same type. By default it will replace, but if you pass in FALSE as the second argument you can force multiple headers of the same type. "

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Re: question on header() function
    ... example it looks like it is for cache control? ... can get some status information from the server? ... conjunction with a header request? ... page unless you wanted the user to download the same data as what he ...
    (comp.lang.php)
  • Re: windows server 2003 cache problem
    ... I dont think you can clear the cache in anways because its kernal mode cache ... Did you try starting IIS or is that not possible on the production server? ... can easily download a file from the local server, ...
    (microsoft.public.windows.server.general)
  • Re: Bitten by old Mail bug...
    ... trainers, eight months ago, while you're on the phone to the shop ... It can cache everything, with most clients. ... The default is to download headers only at first, ... I just keep the whole lot on both server and locally, ...
    (uk.comp.sys.mac)
  • Re: Deleat at server not being accomplished
    ... Some things to note about the Outlook Express version 5+ Message Rules: ... information in the message header. ... must be download first for this test, ... If you just leave messages on the server, ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Now, another question about Xnews
    ... You have 30+ days of retention on a server, ... exactly which header to start at, and which one to stop at. ... you're allowed several connections simultaneously to your ... you to make duplicate servers and download parts ...
    (news.software.readers)