Skip to content

Super Cache: deletes the wrong files during preload #1011

@donnchawp

Description

@donnchawp

Impacted plugin

Super Cache

Quick summary

When WP Super Cache is preloading, it deletes too many files. This happens in two different places.

After every loop of the preload, the homepage is deleted here because of this line:

wpsc_delete_files( get_supercache_dir() );

The original intent was to have a fresh homepage, and when preload was done 100 pages at a time it didn't matter so much, but each preload loop is 10 pages now, so there's more work for sometimes very slow servers to do.

This line runs if preload is set to refresh regularly. It sets the TTL of the cache to the length of time between preloads which will delete files generated before the current preload started. (This is not the couple of seconds between preload loops, it's the 600 minutes or more in between runs of preloads)
By setting the TTL this way, old cache files such as those for categories, tags, archive files and other pages are deleted. This conflicts with the "preload mode" mentioned on the preload page, so the documentation on that page should be updated, or the clean-up disabled.

ref: https://wordpress.org/support/topic/cache-rebuild-does-not-work-nginx-preload-mode/

Steps to reproduce

  1. Set the preload to recur at a regular interval
  2. Start a preload
  3. Note that the homepage cache is deleted on every loop.
  4. When the preload completes, old cache files for archives will be deleted, even if preload mode is selected.

If preload is set to run once, then files older than a day are deleted as part of the clean-up.

A clear and concise description of what you expected to happen.

  1. The homepage shouldn't be deleted on every loop. It should probably be deleted once, at the end, and refreshed.
  2. Archive files shouldn't be deleted at the end of preload, if "preload mode" (which disables garbage collection) is enabled.

What actually happened

  1. The homepage is deleted and must be refreshed on every preload loop.
  2. Old archive files are deleted.

Impact

Not many.

Available workarounds?

No but the platform is still usable

If the above answer is "Yes...", outline the workaround.

No response

Platform (Simple and/or Atomic)

Self-hosted

Logs or notes

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions