Hello!
Simple question: How does one disable caching while one is in development-mode?
While I am developing templates and snippets, I use the get_include_contents () technique so that I may edit the templates and snippet code in an editor, and have the manager just include the file (in the case of a template) or the results of code output (in the case of snippets).
This saves a great deal of time in the highly iterative development stage. However, I find that those time savings are nearly negated since I must go into the Manager and do a "Site Refresh" in order to view the results of my edits in any one iteration cycle
I assume that this is due to the caching mechanism of MODx. Is there a cleaner way of handling this without going into the core code?
Thank you.
Jim
-
MODX Staff
- 12,272 Posts
You know what... that’s a great question. I think we’re in need of another system preference... Raymond... 3.3?
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
Well we can look into such a feature for future versions but as is now we can implement such services. Here’s how:
1) Create a plugin called DisablePageCache
2) Add the following code to the body of the plugin
$modx->documentObject['cacheable'] = 0;
3) Attache the plugin to the OnLoadWebDocument event.
4) Save your plugin and refesh your site and you’re done.
When you’re ready to go Live just disable the plugin and the system will start caching your documents again.
Great idea.
However, I’ve seen caching cause a lot of unforseen issues. If we do this I think it should be an option that is turned off by default with a good warning message when it’s turned on. Otherwise I can see a lot of developers never realizing that certain parts of their site might not be working until they hear about it from visitors.
I don’t know where to do this step:
3) Attache the plugin to the OnLoadWebDocument event.
Where’s that at?
-
☆ A M B ☆
- 24,524 Posts
In the System Events tab of the plugin editing page.
-
☆ A M B ☆
- 24,524 Posts
Changes to .css files should certainly show up, those are not cached; they are requested and retrieved separately from the web page and MODx has nothing to do with that. Your browser may be caching it, but that’s a different matter.
Sorry to include "css" in above post. You are right css files are separate, I meant changes to the templates which in my case also include incline styling.
I checked that it is not the broswer cache. Have that one disabled using WebDeveloper Firefox extension.
Maybe it is just a matter of using a different event.
-
☆ A M B ☆
- 24,524 Posts
Why not just change the default setting in the main Configuration until you’re finished development, then change it back again?