We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14154
    • 5 Posts
    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
      • 25663 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
        • 32963
        • 1,732 Posts
        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.




          xWisdom
          www.xwisdomhtml.com
          The fear of the Lord is the beginning of wisdom:
          MODx Co-Founder - Create and do more with less.
          • 1764
          • 680 Posts
          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.
            • 26958
            • 9 Posts
            I don’t know where to do this step:

            3) Attache the plugin to the OnLoadWebDocument event.

            Where’s that at?
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              In the System Events tab of the plugin editing page.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 12512
                • 42 Posts
                Quote from: xwisdom at Aug 31, 2005, 11:34 PM

                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.

                I am also searching for a solution to disable cache while developing a site. I tried above but it does not work for me (plugin enabled and linked to OnLoadWebDocument event). I still have to uncheck the "chachable" checkbox for evey page I am working on otherwise changes to templates and css won’t show up.
                  • 28042 ☆ 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.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 12512
                    • 42 Posts
                    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.
                      • 28042 ☆ 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?
                        Studying MODX in the desert - http://sottwell.com
                        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                        Join the Slack Community - http://modx.org