We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37942
    • 30 Posts
    Hi everyone,

    Just a quick, and maybe stupid question but i was wondering; how do you guys work with static template files. I've linked some HTML files to chunks and templates but every time i make changes i need to clear the site cache. And for some reason disabling 'Global Cache Settings' in the system settings isn't working either. It is clearly not my browser cache since i use incognito mode for adjusting these templates.

    I hope you guys can help me out here wink Thanks in advance.

    Cheers,
    Nick

    This question has been answered by BobRay. See the first response.

    [ed. note: niintek last edited this post 10 years, 6 months ago.]
    • When you edit the file externally, MODx has no way of knowing that it's been edited, so you would need to clear the cache to have the changes show. When saving templates and chunks in the Manager, the cache is automatically cleared (unless you uncheck that option).
        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
        • 3749
        • 24,544 Posts
        I think you can just reload the page in the Manager too. One problem is that MODX elements don't have an editedon field, so MODX has no good way to tell which is newer, the file or the stuff in the DB.

          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
        • Clearing the cache is a necessary evil with static resources/elements. The convenience factor however can outweigh the evil, and I have been known to use a low down and dirty way to quickly clear the cache without the extra step of clearing the popup. I sometimes open a dummy page, or rather a resource, that I can save over and over again quickly. It takes the menu clicking and pop up "ok" clicking out of the picture for clearing the cache, thus eliminating at least 3 clicks.

          I'd much rather work in an external editor than in MODX. This hacky and dirty method clears the cache as needed when I'm working with a lot of static resources. And one other piece of the puzzle, the quick edit save button is far less buggy than the save button on an open resource (which isn't always highlighted). Shrug... do what works best for you.

            Frogabog- MODX Websites in Portland Oregon
            "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
            Having server issues? These guys have MODX Hosting perfected - SkyToaster
            • 6629
            • 60 Posts
            While developing, i use
            cache_default = 0
            cache_disabled = 1
            cache_resource = 0
            With these settings, every new document is created uncached and template-files aren't cached. Every change to the files is displayed instantly on reload.

            On a live site just invert the settings
            cache_default = 1
            cache_disabled = 0
            cache_resource = 1

            Batcher
            comes in handy to enable/disable caching for a lot of documents before going live.
            • discuss.answer
              • 3749
              • 24,544 Posts
              There is also this: http://modx.com/extras/package/cacheclear which might, or might not, be faster. You can just reload a page with the snippet to clear the cache. It has the advantage (or disadvantage) of clearing parts of the cache that are not cleared when you save a resource or clear the cache manually in the Manager.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 44565
                • 15 Posts
                Quote from: DasItsch at Oct 25, 2013, 09:06 AM
                While developing, i use
                cache_default = 0
                cache_disabled = 1
                cache_resource = 0
                With these settings, every new document is created uncached and template-files aren't cached. Every change to the files is displayed instantly on reload.
                It works. Thanks wink
                  • 37942
                  • 30 Posts
                  Hi Everyone,

                  I tried Dasltsch's option, and this doesn't work for me. However i did tried this option using old resources so i guess thats the difference, so if i'm correct Dasltsch's option only works for new resources? Batcher also didn't work for me, it kept on caching.

                  For me BobRay's option did the magic! Works like a charm! I just embedded his code into the resource it self, so it clears out cache everytime i load the page it self. I'm not sure this is the best way to do it, but for me it works out just fine.

                  Frogabog's option also works great, if your looking for an even easier way to clear the cache i would recommend his aswel. (Saves you the 'hassle' of installing BobRay's CacheClear. So in production environment this might be easier, but when developing i can strongly recommend CacheClear embedded into your resource)

                  However i'm very curious about Dasltsch's option aswel, for some reason it doesn't seem to work for me. Could you maybe confirm that it will only work for new resources?

                  Thanks everyone for participating in this discussion, the power of the community; i love it.

                  Cheers,
                  Nick
                    • 3749
                    • 24,544 Posts
                    It's my understanding that cache_disabled has no effect at all and I can't find any use of it in the MODX code.
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 37942
                      • 30 Posts
                      Thats my conclusion aswel, it doesn't affect the file cache at all. Thanks for pointing out CacheClear. Works like a charm!