Re: [Phplib-users] page expiry problems
Brought to you by:
nhruby,
richardarcher
From: Frank B. <fb...@sy...> - 2003-07-01 19:10:18
|
At 10:50 PM 6/30/03, Layne Weathers wrote: >>>I have a situation where it is easier to generate a static html page with >>>php code (much repetition). The problem is that repeat visits to the same >>>page within one browser session is causing the page to be retrieved from >>>server each time it is viewed. I would like the page to be handled like a >>>static page, based on the file's timestamp on server (since the page is >>>indeed 'static'). >> >>There is no "page" on the server, only a PHP script. >> >>Simple fix: >> >>Backup your PHP script (important!) >>Load the page in your browser >>View Source >>Select All >>Copy >>Open the original script >>Select All >>Paste >>Save > >This is one of the main reasons I have a copy of PHP compiled for command >line usage: > $ ./create_some_page.php > some_page.html > >Start the script with > #!/usr/local/bin/php -q >and make sure it is executable. > >Layne Weathers Thanks for the ideas, but my scripts will be accessed very infrequently and I will not remember to convert them to static pages each time I make changes to them. I have figured out that inserting the following line at top of a script appears to cause browser to cache the page (at least for current browser session, close/reopen browser and pages are retrieved again - as expected). header('Last-Modified: '.date( 'r', filemtime($HTTP_SERVER_VARS['SCRIPT_FILENAME']) )); But scripts that call phplib's page_open function are not affected (ie: not cached) by this change? Frank |