iSun
iSun

Reputation: 1754

Symmetric caching mechanism

I have designed a tiny PHP framework for one of my customers 2 years ago, To make this system faster I implement a simple PHP page caching mechanism.

This simple mechanism require an interval value and compare it with the last time of page modified time, like the following example:

$interval = 5 * 3600;
$filename = ....

if ( file_exists($filename) && (time() - $interval) < filemtime($filename) ) {
    readfile($filename);
    exit();
}

// Rest of the code

Now, according to my customer request I have to make few changes in this Framework and one of the important things in this list is my Caching-System.

My customer says that current mechanism doesn't work symmetrically - e.g assuming that website home-page and category-page follow the above mechanism, Now if my customer add a new item in homepage, the item will first shown in category page and then shown in homepage if both page get expired in two different times.

Is there any way to make this mechanism symmetric without using any external library?

Thanks in advance...

Upvotes: 0

Views: 36

Answers (1)

Calimero
Calimero

Reputation: 4288

What about clearing all cached items whenever a content update happens ? Easy, short and safe.

Upvotes: 2

Related Questions