markowe Posted December 2, 2010 Share Posted December 2, 2010 *delurk! It had to happen sooner or later!* OK, I am totally and utterly stumped. I have this script: $this->clear_cache ($this->cache_dir, $this->cache_time); if ($this->cache_time > 0) { $current_page = $_SERVER ['REQUEST_URI']; $current_page_encoded = base64_encode($current_page); $current_page_path = $this->cache_dir . $current_page_encoded; if (file_exists($current_page_path)) { // see if there is still a file with the name of the current request URI after cache cleared $content = file_get_contents ($current_page_path); return $content; } } Basically, it is for checking if there is a cached version of the page before running the rest of the script, using the REQUEST_URI as the identifier. So it calls a function to clear the cache, which works fine (and I've tried just deleting the cache files manually anyway). Then it checks if we are even caching, i.e. if cache time is greater than 0. Then it uses the BASE64-encoded REQUEST_URI (under which name the file would have been cached previously) to check if a file with that name still exists in the cache dir, and if so loads it. Now, this works perfectly with a url like: mysite/myscript/mysubpage But when the page has parameters, like: mysite/myscript/mysubpage?search=widgets the file_exists function returns TRUE, even though the directory is empty. I did do a clearstatcache(); but it made no difference and anyway, it wouldn't explain why the URI with query string would fail while the regular one would not. And even if something is wrong with my code elsewhere, the fact is it is returning TRUE for a non-existent file. Can someone prevent my slide into insanity?! Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted December 2, 2010 Share Posted December 2, 2010 When you think it is failing, what does this show: echo $current_page_path; Quote Link to comment Share on other sites More sharing options...
markowe Posted December 2, 2010 Author Share Posted December 2, 2010 That's the weird thing (forgot to mention, I tried that) - when I echo that, I get the correct path, complete with the query string! I also tried decoding the BASE64 using an online tool to be sure, and it displays the correct path with query string and all. I am totally bemused, to the extent that I have turned off caching for pages with url parameters, but that's really not the solution long-term! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.