Welcome Guest, Not a member yet? Register   Sign In
CodeIgnitor Caching and Browser Side Caching
#1

[eluser]blasto333[/eluser]
I am creating a report that must NEVER cache on the server or the client. The report is generated via a url similar to:

http://new.phppointofsale.com/index.php/...2009-12-03

If the user refreshes this page, it should never cache on the browser. How can I ensure this or even test for this?

I checked it in firebug and the response header always seems to be 200, but all the css/js is 304 (which is good).

Does this mean that the server logic is always running and the page is never cached?
#2

[eluser]Jelmer[/eluser]
User caching depends on the user's browser which might not work like yours or has different presets. While you can send along HTTP headers and such that should prevent it, you can never be completely sure.

Here's the headers you need to prevent caching and which should always work:
Code:
$this->output->set_header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
$this->output->set_header("Cache-Control: post-check=0, pre-check=0", false);
$this->output->set_header("Pragma: no-cache");
#3

[eluser]blasto333[/eluser]
Thank you, thats what I figured.
#4

[eluser]blasto333[/eluser]
If I append the current timestamp to the url like this:

http://localhost/PHP-Point-Of-Sale/index...9878619410

will that work better?
#5

[eluser]Colin Williams[/eluser]
That wouldn't really work on refreshes/bookmarks though, blasto
#6

[eluser]Jelmer[/eluser]
That solution should work, it's what I use when editing images and I haven't seen it fail.

If you use a timestamp you could have it automatically redirect using Javascript when it's off by too much. That should take care of the possible problem Colin mentioned.

On the other hand I think the headers are the preferred way, all normal browsers should work as expected and it's more bookmarks and search engine friendly.




Theme © iAndrew 2016 - Forum software by © MyBB