Welcome Guest, Not a member yet? Register   Sign In
undesired caching
#1

[eluser]skunkbad[/eluser]
I've got a script that changes the theme of my website, and it works fine, yet when going backwards through the browsing history, aka hitting the back button, the pages don't reflect the session data's theme key being updated, as if the pages are being cached. I have not enabled caching, and the docs say that I would need to for caching to be implemented, so I'm wondering what is going on. Do I need to supply my own no-cache headers or something?
#2

[eluser]Dam1an[/eluser]
Its probably just standard browser cachine... nothing to worry about (assuming a force refresh fixes the problem)

When you change the theme and navigate the site normally, do you still get the cahce effect, or is everything as normal?
#3

[eluser]skunkbad[/eluser]
As long as I'm not going backwards through the browser history, everything is fine, but the browser caching really needs to be stopped, not just for this, but for other programming associated with the site which hasn't been done yet. I'm not at home now, so I can't take a look at the headers, but I'm guessing I will need to insert my own headers for no-cache.

In my procedural version of my site, as well as my Kohana version, this caching doesn't happen. Maybe I just need to clear the cache... I'll have to check it out tonight when I get home from work.

Thanks Dam1an. You're always quick to respond!
#4

[eluser]Dam1an[/eluser]
I still don't really think the backward caching is a big deal, and I'm sure any intelligent user (who cares about this) knows how to clear the cache
Besides, how likely is it a user goes back when they select a new theme, instead of just clicking on a new link?

And I'm only quick to reply between 8:30-5 and 8-11 (other then that I travel, eat and sleep)
#5

[eluser]skunkbad[/eluser]
Well, regardless of how well received the cached version of the pages might be, I quickly fixed the caching issue by adding the following to the top of each controller:

Code:
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
$this->output->set_header("Pragma: no-cache");

I think my preference to put this in each controller warrants the use of some sort of system wide hook, but I haven't got that far yet.
#6

[eluser]Dam1an[/eluser]
Will that not put you under a much heavier load, as yo now have no browser caching?
#7

[eluser]Dregond Rahl[/eluser]
It would cause in the long run a bit of stress, but nothing significant really. Pages maybe a little slower loading though. Honestly though letting the browser cache back information can sometimes be useful.

if you want to set it global why not directly set the headers in the main template file (in view) so it will be there for all pages ?
#8

[eluser]skunkbad[/eluser]
My pages are pretty light, so it won't make a difference, but it theoretically could effect performance.

I ended up making a post_controller_constructor hook which applies the no-cache to all pages. In the end, I'm going to have this site, and the Kohana version up on the production server, and it should be easy to check performance with/without the hook, and vs. Kohana (which always servers up its own no-cache headers).




Theme © iAndrew 2016 - Forum software by © MyBB