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

    Here is the setup and problem:

    I have MODx running as follows

    Server 1:
    MODx manager running on separate domain.
    Also here I have a /preview/ folder that allows my manager users to "preview" unpublished resources, as these will eventually live on a different domain.
    MODx writes to a membase server using. I think this is working but am struggling to confirm.

    cache_resource_handler = cache.XPD0Memcache
    cache_resource_key = resourceCache
    resourceCache_memcached_server = membaseip:port

    I don't get any error when I clear cache or save resources, so I assume its all working (bad idea??)

    Server 2:

    This is the frontend of the site running on a different box.

    Problem:
    When I make changes to a page in the manager and save it, I can view the updated changes fine on my preview url.
    However if I view on the "live" url I see a cached version.

    Problem is the cache does not seems to clear down.
    I have tried setting the cache options in the system settings but can't seem to effect the caching behaviour.

    Any ideas where I might start to fix this issue?
    Thanks in advance smiley

      • 15083
      • 697 Posts
      Update, when I set all the cache to use memcache I get these errors when clearing cache in manager:

      Error caching time of next auto publishing event
      Could not cache context settings for mgr.
      Could not cache context settings for web.
        • 15083
        • 697 Posts
        Found a fix.
        I had to set the system setting:
        memcache_server = yourip:port

        Problem was MODx was looking on localhost for membase, and mine was on a different IP.
          • 22303 MODX Staff
          • 10,725 Posts
          Be aware if using memcache for everything, you need to set all those values in the config_options array in the config file (you'll have to translate the constants as they are not usable in the config file). Otherwise, the System Settings will continue to be loaded from file cache (the default provider). The only way to affect cache settings for System Settings is via this $config_options array.

          Also note that anything with more than 1Mb of data will not be cached since memcache limits cache entries to that size (unless you recompile it to allow more, which I believe makes it less efficient).
            • 15083
            • 697 Posts
            Hi opengeek,

            Thanks for the reply.
            My initial plan was to use memcache for just resource caching, however I found that when I used this approach that changes made in the CMS were not being reflected on the site.

            I tried to set a global cache timeout but this did not seem to work. The only way I got it all working was to use memcache for all caching. When I would unpublish a document via CMS it would remain published on the live...arg!

            Opengeek, can you explain (in lay man terms) how I might setup my config to do the above and avoid the issues I encountered.

              • 15083
              • 697 Posts
              Quote from: opengeek at Nov 15, 2011, 08:50 AM
              Be aware if using memcache for everything, you need to set all those values in the config_options array in the config file (you'll have to translate the constants as they are not usable in the config file). Otherwise, the System Settings will continue to be loaded from file cache (the default provider). The only way to affect cache settings for System Settings is via this $config_options array.

              Just on this: So if I want to change the cache settings, I need to load them into the config array, as they will have been read from cache? Is this correct. Currently im on setting a custom cache path, and everything appears to be working fine?
                • 22303 MODX Staff
                • 10,725 Posts
                Just don't change the cache key when overriding the resource handler. You should leave it as "resource" or it will not get cleared when the site gets refreshed.
                  • 15083
                  • 697 Posts
                  Quote from: opengeek at Nov 15, 2011, 12:29 PM
                  Just don't change the cache key when overriding the resource handler. You should leave it as "resource" or it will not get cleared when the site gets refreshed.

                  Ok so at the moment I have the following system setting set to enable resource caching via memcache (taken from another post of yours!):
                  cache_resource_key "resourceCache"
                  cache_resource_handler "cache.xPDOMemCache"
                  resourceCache_memcached_server "localhost:11211"

                  Are you saying I just remove the cache_resource_key option?
                  I'm not really sure how the above get used, as they are not explained in the caching section of the documentation, sry sad
                    • 22303 MODX Staff
                    • 10,725 Posts
                    Quote from: jusmeig at Nov 15, 2011, 12:43 PM
                    Quote from: opengeek at Nov 15, 2011, 12:29 PM
                    Just don't change the cache key when overriding the resource handler. You should leave it as "resource" or it will not get cleared when the site gets refreshed.

                    Ok so at the moment I have the following system setting set to enable resource caching via memcache (taken from another post of yours!):
                    cache_resource_key "resourceCache"
                    cache_resource_handler "cache.xPDOMemCache"
                    resourceCache_memcached_server "localhost:11211"

                    Are you saying I just remove the cache_resource_key option?
                    I'm not really sure how the above get used, as they are not explained in the caching section of the documentation, sry sad
                    The post you are referring to is quite old. The current advice I am giving you is for MODX 2.1 and above only.

                    In MODX 2.1+, each section of the cache has it's own named partition, and by default the partition which handles Resource caching is called "resource". If you change the cache_resource_key to something else, MODX will not automatically refresh that partition and it will be up to you to write code to do so when you want it to be cleared (or configured so it expires periodically).

                    Prior to 2.1, all of this was a single "partition" and the only way to use a different one was to change the appropriate cache_{partition}_key. This is why the old forum post references things that way.

                    Now you just supply whatever cache_{partition}_{setting} you want to override from the default cache_{setting} values.

                    See the following for more about xPDO and MODX caching...

                    — http://rtfm.modx.com/display/xPDO20/Caching
                    — http://rtfm.modx.com/display/revolution20/Caching

                    FWIW, your memcached_server values can be defined globally if this is the only partition use memcache, e.g.

                    cache_resource_handler => cache.xPDOMemCache
                    memcached_server => localhost:11211,localhost:11212
                    


                    or per partition, e.g.

                    cache_resource_handler => cache.xPDOMemCache
                    resource_memcached_server => localhost:11211,localhost:11212
                    
                      • 15083
                      • 697 Posts
                      Thanks for the reply again.

                      I have read them docs but they fall short of examples/tutorials, and the cache_resource_handler, resource_memcached_server are not referenced at all. While I have a good overview of caching, custom implementations always cause issues.

                      Ok so from my example above, you would only set a cache_resource_key "resourceCache" if you wanted to have multiple resource caches?

                      So if I remove this key then clearing down the cache will work and I wont have to handle this?

                      Also, I set the cache_handler to xPDOFileCache and cache_resource_handler to cache.xPDOMemCache, I cannot call snippets [[cached]]. If I do they output nothing!?! This prompted me to move to memcache for all cache, but this has issues too?