I'm writing a web app, and I'm having a serious problem with too much caching. I use CakePHP 2.0 if that matters at all.
Anyways basically the problem I'm having is the browser caches my app way too often. For example if I have a user fill out a form and then add a flash message and redirect the user to their dashboard the flash message appears just fine, but it appears until I refresh the page. So if I navigate away from that page and navigate back, the flash message is still there. That's just a small irritant, the bigger issues are when pages actually change depending on user action.
For example on the admin side I may update a users status which changes their dashboard in some way. The problem is the updated dashboard will not be seen without a refresh. What a hassle!
My question isn't how to fix this, I know how to stop caching all together. It seems like caching is an important part of a web apps performance though and I don't want to stop caching all together as I can see it slowing things down.
So what is normally done in these situations? Should I just stop the page from caching all together? Seems like an extreme solution. Or should I just link to all of my pages with something like:
http://mywebsite.com/user?t=<?php echo time(); ?>
Or is there something else that I'm missing? Any advice is appreciated!
Would the answers outlined here - How do I completely disable caching in Cakephp? - work?
Fixing the flash message problem is hard - because the flash message is part of the output HTML, there is no way you can get rid of it on a back button event.
For the dashboard, I recommend turning off browser caching ... but that's not going to solve any inbuilt caching that CakePHP has.
Sounds like what you need is some way of invalidating the cache ONLY where there is an update - you could add a method to your add()/edit() methods to completely delete the cache upon a successful save() event - that seems the only foolproof method that would work for your case.