Peter Van Dijck schrieb:
Hi all,
I am using a caching identifier based on the URL. But I'm getting
strange effects: when accessing a URL I see the cached version of
*another* page.

This is the code I'm using for the cache identifier.

$cache_identifier = ereg_replace("/", "_", $_SERVER['REQUEST_URI']);
Here you replace / with _ from REQUEST_URI
$cache_identifier = ereg_replace(".", "_", $_SERVER['REQUEST_URI']);
Here you replace . with _ also from REQUEST_URI and overwrite the cache_identifier. The line before has no effect.
$cache_identifier = preg_replace("/([^a-zA-Z0-9_-])/", '', $cache_identifier);
Here you remove all non-allowed characters. This includes /, which is not replaced because the first replacement take no part. Also replacement with nothing is not such a good idea, because maybe youre missing an important seperator. Its better you replace with a character instead.

I think, you should dump both the wrong-cached- and the "real"-page-identifier and compare them.
I added that last line because I was getting errors saying that the
cache identifier could only have a-z and _- characters.

Any thoughts on how to improve this would be very welcome :)

Thanks!
Peter


Reply via email to