Snippets - Little bits of code to make you happy
Automatically ?flush when in 'dev' mode
Tweet15 April 2010 | | | Supports v2.4, v2.3
Often when doing development work on a website - and particularly the templates - it can be a pain having to remember to add ?flush to the end of the URL to make sure all of your changes have come through. I'm sure that all of us have had that "d'oh" moment when we have spent too much time wondering why our changes weren't working, only to find a simple flush fixed it.
If you have set up a domain in your set_dev_servers array or added Director::set_environment_type('dev') to your _config.php file then you can also add:
if (Director::isDev()) {
SSViewer::flush_template_cache();
}
This will flush the template cache on every page load.
NB: This will not regenerate cached images, if you want to do that you will have to add $_GET['flush'] = 1; inside the above conditional statement.
4 Comments
RSS feed for comments on this page RSS feed for all comments
alex
15/11/2010 8:39pm (1 year ago)
Is this how it should look adding the conditional statement?
if (Director::isDev()) {
SSViewer::flush_template_cache(); $_GET['flush'] = 1;
}
Sorry pretty new to all this, thanks - alex
Daniel Hensby
15/11/2010 9:15pm (1 year ago)
Yep, looks good!
swaiba
07/01/2011 2:50pm (1 year ago)
I just posted on the _config.php cheatsheet because this fragment caused the site to continuously error in dev mode so I had to remove it
aleks
23/02/2011 12:32am (12 months ago)
Many thanks for this!
Saved my over-annoyance meter from exploding right now.
Post a comment ...
You cannot post comments until you have logged in. Login Here.