Making an Advanced cache system

Hello,

I’m programming an advanced caching system that work with PHP but i have an small problem.

I want to know when the pages content changed to remove the page cache from cache folder and make a new cache file with new content.

i don’t want to work with cache time…

Please help me, thanks a lot.

Any idea?

(Excuse me for spamming)

Thank you dear logic_earth for your response,

Yes, i can modify or edit my cache page and this is not necessary to delete the cache.

Could you not just delete the cache when you update the page’s content?

Caching might get messy if you don’t want to use expiration times.
You’ll need some kind of reference to check if there were any changes made.

You could use filemtime() in combination with timestamps of the last modification of the editable components.
This means you’ll still have to query a database -assuming the timestamps are stored along the data in the database- to get the timestamps to compare them with the filemtime of the cached file.

In my experience, caching with expiration times and cache ‘namespaces’ work best.
With every change the cache is cleared for that component or the entire namespace where that component is located.

Thanks dear hexburner, so useful

But i want to know your algorithm to check how pages content changed, i can’t understand your mean about :

You could use filemtime() in combination with timestamps of the last modification of the editable components.
This means you’ll still have to query a database -assuming the timestamps are stored along the data in the database- to get the timestamps to compare them with the filemtime of the cached file.

and just another, whats mean ‘namespaces’ cache?

Thank you dear friend :slight_smile: