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

    I use static files for my site template so that I can use my local editor.

    Problem: When I changed an uploaded the template file, modx does not recognize it and uses the old template files until I clear the cache.

    That is an annoying extra step. Is there a way to disable caching only for template files?

    Thanks!
    J.
    • No; Templates are the foundational Element of a Resource, and in order to see changes to a Template, whether or not they are stored in static files or in the database, you must refresh the cache or mark the Resource uncacheable.
      • If your concern is only about HTML/CSS, one workaround could be to use an uncached include snippet to load your template html. Ex.

        [[!include? &file=`path/to/your/template.html`]]


        But, as discussed with opengeek, you will end up with an unexpected caching behavior (resources, and their content/snippets/..., using this template won't be cached).

        Not sure it worth the trouble (you should be soon enough used to clear the cache after a template modification ^^).

        Hope this will help
        • I do the same, but css files apparently aren't being cached so if I make a change in the css I can see it without clearing the cache.

          However, to reduce the annoyance factor and eliminate a couple of clicks you can employ a clear cache button in your menu. See :http://forums.modx.com/thread/?thread=73029#dis-post-406537 for more information. I'm so in love with my new clear cache button!
            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
            • 38741
            • 4 Posts
            What you could do:

            01. - create a chunk with the name "template" ( or what ever )
            02. - set chunk to : "is static"
            03. - select your template file & save chunk
            04. - create a template ( normal, not static )
            05. - then call the chunk: [[!$template]] ( be sure to call it with ! )
            06. - You're ready to go, refresh the browser and changes are direct !
            ---
            Optional:
            use the plugin: http://livereload.com/
            Then you don't even have to reload the browser manually

              • 36491
              • 36 Posts
              Thanks to all suggestions. I found that the most elegant solution for me would be to have example resources that are uncached for checking changes in the templates.

              It really speeds things up for me to be able to use my favorite editor (sublime text 2) locally to develop templates in a live modx environment instead of building a single html-file first offline and chopping it up later into templates and chunks in modx. The files are uploaded instantaneously via a virtual ftp file system on linux.
                • 38741
                • 4 Posts
                I prefer to mount the server on my desktop, and handle the files as they are local files. So basically having a slow HD. That way I can edit photo's directly on the server with photoshop and use whatever text editor I want. ( ps Love the script mini map in Sublime 2, but prefer BBedit )

                  • 37329
                  • 10 Posts
                  I found the batcher add-on very usefull for switching all resources to 'non cacheable'.
                  A very handy component.

                  http://modx.com/extras/package/batcher