Jump to content

Fast Self-Updating Cache


ShogunWarrior

Recommended Posts

This is a cache theory I've been thinking about for a while but have never seen implemented.

The basic theory is that at the top of the page there is a PHP-check (such as page age check) and if the page needs to be refreshed a script is run.

E.g. The page [b]blog_post_2006_12_22_comments.php[/b] begins:
[code]
<?php
$timestamp = 1167787321;
if( ( time()-$timestamp )>30 )
    { $file = 'blog_post_2006_12_22_comments.php'; include('refresh_cache.php'); }
?>
[/code]

In refresh cache you could have any code but basically it would output the content of the file with the previous code prepended to it to check itself.

Where I believe there is an advantage is that other than the very simple date check there is no overhead where you would normally have to load the contents of a file into a PHP string and then output it.

However, I'm not sure if it is possible that the file will lock or will throw errors if it tries to rewrite the file (because it is being run).
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.