• Resolved PumpaXXL

    (@pumpaxxl)


    Hi,

    I’d like to refresh the whole cache (about 280 pages) once per day at 1 am. My settings are…

    1) wp-cron: disabled
    2) external cron 1: set to 5 minutes periods
    3) external cron 2: executing cache-refresh.php at 1am each day
    4) cache lifespan: 25 hours (as backup if 1 a.m. cron fails)
    6) preload – schedule type: “same as cache lifespan”

    My cache-refresh.php file in the web root folder contains the following code:

    <?php
    // Load WordPress.
    require( ‘wp-load.php’ );

    // Clear cache.
    if ( function_exists( ‘WP_Optimize()->get_page_cache()->purge’ ) ) {
    WP_Optimize()->get_page_cache()->purge();
    }

    Can you please…

    1) Confirm the settings are ok.
    2) Suggest the content of cache-refresh.php file. It doesn’t work at the moment. If a cache preload trigger function is needed after the cache purge to start the preload, please include this one also.

    Thanks, great plugin!

    • This topic was modified 2 years, 9 months ago by PumpaXXL.
Viewing 4 replies - 1 through 4 (of 4 total)
  • @pumpaxxl Please try to add the function to a hook instead.

    add_action('init','purge_cache');
    
    function purge_cache(){
    if ( function_exists( ‘WP_Optimize()->get_page_cache()->purge’ ) ) {
    WP_Optimize()->get_page_cache()->purge();
    }
    }

    Let us know if above code helps to fix the issue?

    Thread Starter PumpaXXL

    (@pumpaxxl)

    Thanks, Harshad.

    Hi @pumpaxxl,

    Do you have the script working? I am also looking for a script / php snippet to clear the cache on a specific time.

    Please let me know.

    Many thanks.

    Thread Starter PumpaXXL

    (@pumpaxxl)

    Hi @iamonline,

    we decided to go with different caching plugin but as far as I remember, the cache purged worked in php snippets but not in the php file. Also I am not sure if it triggered the cache preload.

    Please let me know if you get it working as was intended.
    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Cron cache refresh once a day’ is closed to new replies.