Forum

Howto X-Hiawatha-Cache and X-Hiawatha-Cache-Remove

Mike
29 April 2012, 04:06
Hiawatha version: 8.2
Operating System: Ubuntu

Hello Hugo,

Could you show us and example how the X-Hiawatha-Cache and X-Hiawatha-Cache-Remove should be used in PHP to improve website caching? The manual is not very clear to me in this situation. I have an idea, but I'm not sure if that works.

Thanks
Hugo Leisink
29 April 2012, 09:29
If you want Hiawatha to cache the output of a PHP script for 100 seconds, use this command:
header("X-Hiawatha-Cache: 100");

If the URL of the script is called again within 100 seconds, Hiawatha sends the content from the cache. After 100 seconds, the output is removed from the cache.

Assume the name of the script mentioned above is /script.php. If you want Hiawatha to dump the output of a PHP script, send the following command:
header("X-Hiawatha-Cache-Remove: /script.php");

This can of course not be done by script.php itself, because it's not called again within the 100 seconds. It should be done by another script.

How to use this effectively: within a CMS/framework, use the X-Hiawatha-Cache header in the script that outputs static pages from the database. Use the X-Hiawatha-Cache-Remove within the admin script that can be used to maintain/edit the static pages in the database.
This topic has been closed.