jacobwb / hashover

Free and Open Source PHP Comment System

Home Page:http://tildehash.com/?page=hashover

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cache-Issue when using javascript-mode

q2apro opened this issue · comments

I noticed when using the javascript mode that the page is not updating the comments when adding a new one or deleting an old one. Just after a manual page reload the changes are visible.

I assume that javascript gets cached (probably by ZLIB, default from my server).

To prevent caching, you can add a timestamp to the embed, see other methods here: http://stackoverflow.com/q/118884/1066234

For the recent hashover script, I have done this by PHP:

document.write(\'<script src="http://www.echteinfach.tv/hashover.php\' + canon_url + \'&v='.time().'"><\/script>\');

&v='.time().' will always give the current time, so the script gets never cached.

The disadvantage is, that the server has to load more data this way.

Update:
Cannot use this methode because hashover takes the time string as well for creating the page!

→ A better solution would probably be to tell the embed script, that an action was taken place and that it should reload / refresh itself. This could be done by appending the action event as an identifier to the URL.

This has been fixed in the upcoming code push.

Place these lines in the PHP code at the top of javascript-mode.php

// Disable browser cache
header('Expires: Tues, 08 May 1991 12:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');

Thanks. When do you push your new code to the repo?