Re: included files cached??
| From: | Marek Kilimajer | Date: | Thu, 10 Apr 2003 10:05:46 +0000 |
| Subject: | Re: included files cached?? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143300@lists.php.net to get a copy of this message | ||
This has nothing to do with the browser, it happens within single run. I noticed that under certain conditions this code would not work:
<?php
if(!file_exists('hello.txt') || filemtime('hello.txt') < (time() - 5) ) {
$f=fopen('hello.txt','w');
fputs($f,'Hello World!<br>Current time is'.date('H:i:s',time()));
fclose($f);
clearstatcache();
}
include('hello.txt');
?>
The code needs to be more complicated than this to show the bug, I could reproduce the problem only in code 500+ lines long (the code was checked inside out). I know I did not use file locking in this example, but this is not problem because I know I'm the only one accessing the file. I found another coder having the same problem, check the archives for subject "including just created file" from Richard Lynch
Rich Choy wrote:
Not sure if this will work, but have you tried tweaking Pragma and Cache-Control headers? "Marek Kilimajer" <kilimajer@webglobe.sk> wrote in message news:3E945497.3050608@webglobe.sk...Yes, I have seen this, and I left using include files and chose sql to store the pages. Seems like a bug. Jim wrote:PHP4's.does PHP or apache do some sort of caching when you use include()? I've had repeated problems with this using various Apache 1.3's andtoThe page that include()s some included_file.php doesn't see any changestheincluded_file.php until i force it to "echo" something which "wakes up"nofile. But this doesn't even always work. right now we are goiing crazy with this: main_file.php <? ini_set('display_errors',1); // trying to find the problem! include('/absolute_path/init_file.php'); ?> init_file.php <? include('/absolute_path/included_file1.php'); ?> <? include('/absolute_path/included_file2.php'); ?> included_file2.php <? echo "<h1>here I am!</h1>"; ?> we just added the line that includes include_file2.php (and the file itself). the site was already working for some time just fine. there iswarning or error with include_file2 - nothing happens. file_exists('/absolute_path/included_file2.php') returns true! anybody out there seen this?