• Hi,

    Enable Media Replace doesn’t replace images in content when using an object cache plugin. Media replacement succeeds, but the media isn’t updated in content. Instead, the original image disappears (404) and nothing is shown.

    Before replacing the media :

    After replacing :

    Step to reproduce :

    1. Install an Object cache plugin (see list below)
    2. In the plugin settings, activate Object cache
    3. Upload a media to the media library
    4. Add the media to a sample page and publish it
    5. With EMR, replace the media using these settings :
      • Replace the file, use the new file name, and update all links
      • Replace the date with the current date
    6. From the front end, access the sample page and add ?nocache to the end of the URL
    7. Open the browser devtools “Network” tab, disable cache and reload the page
    8. The original media is gone, and the replaced version doesn’t show

    This issue has been tested with an blank, up-to-date WordPress installation, and only Enable Media Replace (4.1.7) and an Object cache plugin installed.

    It was successfully reproduced with the following plugins :

    • APCu Manager (4.3.0)
    • atec Cache Info (1.8.31)
    • Docket Cache (24.07.05)
    • SQLIte Object cache (1.6)
    • Redis Object Cache (2.7)

    Issue occurred both on LiteSpeed and Apache servers, hosted by four different hosting companies. So I do think that the problem lies on Enable Media Replace side.

    Disabling Object cache or removing the cache plugin solves the issue.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Adrian

    (@adrianrus)

    Hi @g4ll4is ,

    Thank you for your message! I’m sorry to hear about this issue 🙁

    Could you please confirm that not even purging the cache from the object cache plugin fixes the issue after the image has been replaced?

    Looking forward to your reply so we can investigate this further!

    All the best,

    Thread Starter Guillaume G.

    (@g4ll4is)

    Purging the object cache does fix the issue. The new image shows in content after that.

    But purging only works when any other cache is disabled, which is rarely the case in production. With other caching systems active (page, opcache, CDN), purging object cache doesn’t fix anything.

    As object cache fails, others caching systems will store and serve outdated info. You end up purging every cache system to restore the rightful media.

    FYI I’ve first discovered this issue in late 2024, using EMR 4.1.5. But I wasn’t able to reproduce it back then, and this took me some time to pinpoint what was wrong.

    Plugin Support Adrian

    (@adrianrus)

    Hi again, @g4ll4is ,

    Unfortunately, this doesn’t seem to be an EMR issue, it seems to be a normal caching issue.

    The plugin replaces the image correctly, but you’ll need to clear your caching afterward to ensure the updated image displays properly. When multiple caching layers are active, there’s always a risk of showing outdated content if the cache isn’t purged, this is because EMR cannot purge the cache from other plugins.
    After replacing an image with EMR, you need to purge both the normal cache and object cache. Once cleared, the new image should display correctly!

    Hello @adrianrus !

    @adrianrus

    Unfortunately, this doesn’t seem to be an EMR issue, it seems to be a normal caching issue.

    I’m sorry, but I don’t entirely agree with that… It is the “responsibility” of the process that modifies content to inform the object cache manager that the content is stalled.
    In this present case, EMR must explicitly delete the cached versions of the media: it is the only one that knows that the cached media is no longer valid… wp_cache_delete() is your friend 😉

    Plugin Author Pedro

    (@petredobrescu)

    Hello @pierrelannoy and thanks for your reply!

    We are already using WP’s cache flushing methods, including wp_cache_delete(), so this is not the real issue here. Most likely, we need to integrate with the plugins above. We’re running tests by default with memcached and the default WordPress object caching, which works without issues. We’ll do our best to run tests with the plugins listed above and see what we can do to achieve the cache flushing needed for a seamless experience.

    I take this opportunity to mention that this is a free plugin, and we always welcome pull requests with such integration/fixes in our GitHub repository:

    https://github.com/short-pixel-optimizer/enable-media-replace

    All the best

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.