WordPress Plugin: Cache Time
Timing is important. We look at watches and clocks often throughout the day, as most of us have a busy schedule. With websites, it is often advantageous to know when the current page has been written or created.
That is why I have written this simple WordPress plugin for websites. At first glance it appears to be a basic plugin that displays the current time, but there is much more behind the scenes.
Cache Time displays the time that the current page was cached, or, if the page is not part of the caching system, it shows the current time. It is smart enough to take into consideration the time zone of the WordPress installation, and it checks the WP-Cache configuration file for any URLs that are not supposed to be cached. My website is currently displaying this information in the footer.
Tested up to the latest version of WordPress, 2.6.
- Officially, the only supported caching system is WP-cache, though I have not tested WP-Super-Cache.
- Upload the plugin to your WordPress plugins folder.
- Inside the WP admin panel, activate plugin.
- Wherever you wish to display the information, use
inside your Template pages
There are 3 elements that can be customized with Cache Time:
- Text displayed when page is cached
cache-time.phpinside the Cache-time folder with your favorite text editor and find line 27 that says
$cached = 'Page cached on: ';. Change the text between the quotes for your own message.
- Text displayed if no cache is present
Similar to above, find line 29 that says
$not_cached = 'Time is now: ';and change the text between the quotes.
- Date Format
Again inside the cache-time.php file, line 36 can be changed to display your choice of information. More details about customizing the date can be found at w3schools.
What is the point of this plugin?
Cache Time is meant to display the time that your website last cached the current page, for both you and your users’ benefit. There are many instances where users want the most current information, and this is an easy way to show how current that info is.
Is WP-Cache the only caching plugin that works with Cache Time?
Officially, yes. I have not been able to fully test WP-Super-Cache yet, but I believe it would work the same way.
OK, but what I don’t have WP-cache installed?
If no caching system is installed, the plugin simply displays the current time.
v1.0 –– May 14, 2008
* Initial release
v1.01 — May 19, 2008
* update the readme file
v1.0.2 — July 28, 2008
* Cleaned up code and readme file
[tags]Wordpress, plugin, websites[/tags]