We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14883 ☆ A M B ☆
    • 450 Posts
    I am finally getting around to looking at speed testing and optimization of my MODX websites. I know all about cached/uncached resources, elements, etc. But I know very little about caching when it comes to actual HTTP response headers. I'm looking at headers in Firebug, for a cached resource (set to cacheable in MODX), and seeing this (see attachment):
    Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Connection Keep-Alive
    Content-Type text/html; charset=UTF-8
    Date Tue, 30 Apr 2013 19:10:26 GMT
    Expires Thu, 19 Nov 1981 08:52:00 GMT
    Keep-Alive timeout=5, max=100
    Pragma no-cache

    All of this no-cache and way-in-the-past "Expires" date seems rather bizarre for what is supposed to be a cached resource.

    I tested a static html file, and a php file, from my same web server, and did not see such extreme no-cache directives. So is MODX putting these headers in? If so, why? And can I change it?

    Can someone help me understand what is going on here? Because I have no idea.
      • 14883 ☆ A M B ☆
      • 450 Posts
      Okay, so I found this:
      http://tracker.modx.com/issues/3995
      This is not a bug—this is how PHP sites that use sessions must operate. If you want to modify your session.cache_limiter for all requests and allow caching of your dynamic MODX Resources on client/proxy, feel free, but do not complain when dynamic, user-sensitive, or other session-sensitive data is not seen by your visitors when you make changes.
        • 42046
        • 436 Posts
        It's your server setting the cache headers not MODX.

        Assuming you're using Apache and your server is configured to allow you to control these, have a look at the following documents for controlling the caching via htaccess:

        http://www.askapache.com/htaccess/apache-speed-cache-control.html


        http://www.askapache.com/htaccess/speed-up-sites-with-htaccess-caching.html


        I would only enable caching for static files though, limit it too images, css, javascript etc.

        edit: For static files though it's easier to do with adding version control which modern browsers will obey. Just append css paths etc with something like myfile.css?v=1.0
          • 22303 MODX Staff
          • 10,725 Posts
          FWIW, I released a package last week called microcache that will allow you to control the HTTP caching headers in various ways across your MODX Resources.
            • 38525
            • 26 Posts
            @opengeek: Thanks for releasing microcache, awesome little plugin! I was having the same problem as TS while using this LESS compiler... The browser wouldn't cache the compiled stylesheet, so it was loaded again on every page request. Now it seems to behave like any regular CSS file smiley

            Only thing is that you manually need to set the Plugin to listen to the OnWebPagePrerender event. You do this by clicking the Plugin's name in the Elements tree, go to the "System Events" tab, scroll to the very bottom, enable the OnWebPagePrerender event, and save. Thanks to Sepia River for this information!
              • 41354
              • 9 Posts
              Hi. Sorry for digging up an old post, but I have the same issue,even after installing Microcache. I still have the same headers as the OP.
              The plugins seems to be installed correctly and it is hooked into the OnWebPagePrerender event.

              Thank you for any assistance.

              EDIT: I got it working, not sure which of these did the trick but I cleared the browser cache (pages shouldn't be cached but who knows) and regenerated the system URIs from within MODx. [ed. note: andreast last edited this post 11 years, 7 months ago.]