• Hi all,

    Somehow the page cache on my website is removing itself every 60 minutes. The page cache method I am using is disk basic. In the advanced settings I already edited the “Garbage collection interval” into 604800. I also inserted the code below into the functions.php file.

    add_filter('w3tc_pgcache_lifetime', function($request_uri, $time) {
        if( $request_uri == '/' ){
            $time = 604800;
        }
        return $time;
    });

    It would be really great if someone can assist me.

    Thanks

    Tim.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter timmen22

    (@timmen22)

    I have also looked into the active cron jobs, but I do not see anything which looks suspicious. The page cache flushes itself after exactly 3600 seconds (1hour) so it must be something like a cronjob.

    If anyone can help me that would be great.

    Hey @timmen22,

    Perhaps not directly related to the problem you’re facing, but worth mentioning: The filter function you mention above only works on the community edition of W3TC.

    Also, the parameters are reversed, it should be:

    add_filter('w3tc_pgcache_lifetime', function($time, $request_uri) {
        if( $request_uri == '/' ){
            $time = 604800;
        }
        return $time;
    },10,2);
    • This reply was modified 8 years, 2 months ago by charleslf.

    Now, going back to your problem.

    What is the value of “Expires header lifetime” in Performance => Browser Cache.

    The TTL of page cache files is set via the “Expires header lifetime” field in the “HTML” section on Browser Cache Settings tab.

    Thread Starter timmen22

    (@timmen22)

    Thanks for helping me Charles.

    The “expires header lifetime” value is set to 604800. I also removed the snippet since I am not using the community version. Thanks for pointing it out!

    Thread Starter timmen22

    (@timmen22)

    I noticed that in my export the following value is set: pgcache.lifetime’ => 3600,

    It looks like the value can’t be edited from the admin panel. Is there anyway to hook into the plugin without editing the core?

    Thank in advance.

    Tim

    Thread Starter timmen22

    (@timmen22)

    Solution:

    In order to edit the lifetime of cached pages I exported the configuration settings. You can find it under the tab “General Settings”. Open the export and find/edit the ‘pgcache.lifetime’ value into the number you want. (time in seconds).

    I think this value need’s to be editable through the admin panel. Maybe a great suggestion for a future update.

    Once again, thanks for your help Charles! This topic can be closed.

    Tim, out of curiosity what Page Cache Mode are you using? I know the pgcache.lifetime field is made visible and adjustable on the admin page (under Page Cache) when not using Disk: Basic and Disk: Enhanced even though i’m pretty sure pgcache.lifetime also has an effect on Disk: Basic entries even though it’s not visible on the admin page. Thanks for the info.

    Hi Kimberly,

    I’m not Tim but I’ve found that the “Expires header lifetime” value is [probably] honoured with “disk: enhanced” mode but is ignored with “disk: basic” mode.

    I was using basic and noted that ‘public_html/wp-content/cache/page” rarely contained a file/directory more than and hour or 2 old and regularly cleaned itself out. I guess that would make sense if it was using a “stealth” setting of 3600s from pgcache.lifetime.

    I switched to “disk enhanced” and “public_html/wp-content/cache/page_enhanced” had files 6 hours old before I switched back to basic (which I did to cache URLs with query strings). So that did seem to be honouring the 24 hour TTL.

    Selected values from my config export:
    “pgcache.enabled”: “1”,
    “pgcache.comment_cookie_ttl”: “1800”,
    “pgcache.engine”: “file”,
    “pgcache.file.gc”: “3600”,
    “pgcache.lifetime”: 3600,
    “browsercache.html.lifetime”: “86400”,

    I might try the “editing exported config file” workaround but it’s unfortunate that it seems to be inconsistent with cache TTLs dependent on method, and the on screen documentation is inaccurate.

    For now I’ve just set GC to 24 hours.

    Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Page Cache automatically clears every 60 minutes’ is closed to new replies.