No internet connection
  1. Home
  2. Support

v7: Cache sometimes not being updated

By Stefan @stevygee2020-03-20 12:41:53.287Z

I'm having an issue where sometimes a change on a page doesn't make it to the wp2static export. In this case, switching out an image in an image block. Instead, I find an old version of the page in the export with the old image. Clearing the wp2static caches and exporting again gives me the desired result, but that's an extra step to do and takes longer.

I originally thought that my caching plugin (WP Rocket) was to blame. I have since disabled any caching plugins, removed WP_CACHE from wp-config.php and also the file advanced-cache.php. The issue still persists.

How does wp2static v7 determine if a page has been updated? What can I try to help debug this?

  • 3 replies
  1. Leon Stafford @leonstafford2020-03-20 13:41:35.352Z

    OK, this is exactly the type of issue I was hoping for - thanks! Current v7 builds have most basic change detection, which I think is post create/update/delete, but going to add as many options as make sense for user control.

    I would have thought that switching an image block out would have triggered a post save/update call, but haven't tested that explicitly. If you can reproduce/narrow down what event is firing here.

    Currently, it's the method wp2static_save_post_handler() from src/Controller.php which is registered against the save_post handler in src/WordPressAdmin.php

    1. SStefan @stevygee2020-03-23 12:31:31.280Z

      Thanks, I'll keep an eye out and once I get a chance to test more, I'll let you know of the results. Today I updated a menu and this change also didn't make it to the export (until I cleared the cache).

      As a workaround, I want WP2Static to always start fresh, without using the cache. Is there a way to disable the caching functionality entirely via a filter?

      1. Leon Stafford @leonstafford2020-03-23 14:42:57.527Z

        Hi @stevygee,

        Ah, good, yes, menu update should be another trigger we allow registering for, along with theme change, etc.

        So, I don't think there's an action/hook available yet for the cache clearings, but there is a static method you can call for most caches, something like \WP2Static\CrawlCache::truncate() but we should definitely get those hooks in to make it easier