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

    I am playing around with Varnish on a MODX installation and have a few questions about how MODX handles sessions and logged in users.

    If I turn off sessions on my web context (using: session_enabled=0) I can see this is being served by Varnish successfully as no session is being created.

    If I leave it on, I can see that MODX is setting the following headers:

    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma: no-cache


    This prevents Varnish from caching the page as it thinks it is different for each user. I know Varnish also won't cache if it sees cookies but this is something I can control in the Varnish settings.

    The problem I have is that 90% of the site is static apart from something like /members/*
    I would like to be able to set rules that mean certain locations are not cache in the Varnish settings which should be no problem.

    Is there a way of telling MODX not to create a session until the user logs in?

    I would be really interested to see how everyone else is using Varnish and get some pointers.

    Thanks,
      Stewart
      Freelance Web Designer & Developer:
      http://www.qodo.co.uk

      My extras:
      TwitterX http://modx.com/extras/package/twitterx
      TableOfContentsX http://modx.com/extras/package/tableofcontentsx
      • 34926
      • 87 Posts
      Take a look at session-cache-limiter. By default PHP sets this to 'nocache' - hence your header. I'm not sure if MODX sets this header but if it does you can probably write a plugin to change it.
        • 24168
        • 45 Posts
        Thanks.

        Just found this which might be interesting:

        https://github.com/opengeek/microcache/wiki
          Stewart
          Freelance Web Designer & Developer:
          http://www.qodo.co.uk

          My extras:
          TwitterX http://modx.com/extras/package/twitterx
          TableOfContentsX http://modx.com/extras/package/tableofcontentsx