We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36635
    • 41 Posts
    Hi, I'd like to modify a document's content that is cached and returned to browser. I see that OnWebPagePrerender is called on each page load. I want to replace image sources with a CDN host but I'd prefer to not have that run on every page load, just save the changed contents in cache. I didn't see an event called before saving to cache where I could modify contents and have those cached and returned to browser. And I don't want these changes visible to editing so that images in the document are kept path/host free since we have local copies already.

    Any ideas? Seems like a good place for an event for a plugin so we can muck with output and have that persist till cache is cleared and not effect editing.

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

    • discuss.answer
      • 40045
      • 534 Posts
      How about OnBeforeSaveWebPageCache http://rtfm.modx.com/display/revolution20/OnBeforeSaveWebPageCache.

      I don't know if this is suitable for your scenario but I probably would try to write a plugin which would be attached to this system event. I'm not sure if this event is always fired (ie also when a resource is already cached), so maybe somebody with deeper knowledge of events can point that out?!
        • 36635
        • 41 Posts
        Perfect, can't believe I missed that. Thanks much!
        Fired just before cache save and page reloads do not re-fire, just what I need.