• Resolved CB

    (@cbrandt)


    Hi guys,

    I’m creating a website that will have a home page that will show a random post. This part is done, but I don’t want a different post each time a visitor comes in.

    I’m wondering if it would be possible with WP Super Cache to set it in a way that the home page would be cached, but this cache would expire at midnight each day, then be redone whenever some new visitor comes to the site.

    Is this possible? What settings should I apply? Can this otherwise be done with a Cache Control header?

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • The plugin can’t expire a page at a certain time but you could write a small script to delete the cached file for the homepage and schedule it to run at midnight through the WordPress cron.

    The cached file will be wp-content/cache/supercache/yourdomain.tld/index*

    Once deleted the page will be cached again when someone visits the page.

    Thread Starter CB

    (@cbrandt)

    Thank you.

    Once deleted the page will be cached again when someone visits the page.

    And since the cache for that page would be deleted, and not become stale, the new caching would be independent of the Garbage Collection setting, right?

    Thread Starter CB

    (@cbrandt)

    Actually, I cannot find the file at the provided path.

    Instead, I see two php files with filenames starting with /wp-cache- and /meta-wp-cache- followed by long random strings.

    Should I remove these two files instead of the /index* one?

    Yup. Unfortunately the random strings will change depending on your cookie settings and who visits so you might have to open the directory in PHP and look for files with those two prefixes and delete them all.

    Thread Starter CB

    (@cbrandt)

    Thanks a lot!

    I’ve already tested a cronjob to remove /wp-cache-* and /meta-wp-cache* and it works as intended.

    • This reply was modified 4 years, 6 months ago by CB.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Set the cache for home page to expire at midnight’ is closed to new replies.