Support » Plugin: W3 Total Cache » maintenance.php being cached

  • Resolved Vicky

    (@vickymedrano)


    Hi, I hope someone can help me with this.
    I use a maintenance.php to customize the maintenance page, as described in WordPress Codex. The file is placed in /wp-content and will only be called by WordPress when entering in maintenance mode naturally.
    I don’t want it to be cached for obvious reasons.
    I’ve already set the right headers, and also added “maintenance” and “maintenance.\php” to the page W3TC exception list, although it’s not really a page.
    The maintenance page works fine, but it’s being cached.
    How can I prevent it from being cached?

    These are the headers from my maintenance.php:

    $protocol = “HTTP/1.0”;
    if ( “HTTP/1.1” == $_SERVER[“SERVER_PROTOCOL”] )
    $protocol = “HTTP/1.1”;
    header( “$protocol 503 Service Unavailable”, true, 503 );
    header( “Retry-After: 600” );
    header(‘Cache-Control: no-cache, no-store, must-revalidate’);
    header(‘Pragma: no-cache’);
    header(‘Expires: 0’);

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @vickymedrano

    Thank you for your inquiry and I am happy to assist you with this.
    Depending on the name of the page, you can add it to the Performance>Page Cache>” Never Cache following pages” filled, for example, if it’s called https://yourwebsite/maintenance/ simply add /maintenance/ to the mentioned filed, save all settings and purge the cache.
    I hope this helps!
    Thanks!

    Thread Starter Vicky

    (@vickymedrano)

    Hi Marko, thanks so much for your fast response.
    Unfortunately adding /maintenance/ to the page cache exception list doesn’t work, because it’s not really a page, but a WordPress built in mode.
    Is there any way to make W3TC honor the 503 status sent by the header of the maintenance mode, and NOT cache the homepage?

    Also, I want to mention that same behaviour happens if I put the site in maintenance mode using a plugin that calls the /wp-content/maintenance.php. The plugin is very well known (Coming Soon Page, Under Construction & Maintenance Mode by SeedProd). I want to stress the fact that maintenance.php is a built in feature of WordPress, I’ve just customized the appearance of the resulting homepage, as the WP Codex indicates we can do.

    Thanks for your time, I hope we can solve this.

    • This reply was modified 1 year ago by Vicky.
    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @vickymedrano

    I am sorry about the confusion, now I am understanding what you are saying.
    As I was unable to replicate the issue, have you tried adding the constant define('DONOTCACHEPAGE', true); to maintenance.php which will exclude it from being cached?
    Thanks!

    Thread Starter Vicky

    (@vickymedrano)

    Hi Marko,

    It worked like a charm. Thank you so much for your assistance.
    I’m marking the post a RESOLVED.
    Have a nice day!

    • This reply was modified 1 year ago by Vicky.
    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @vickymedrano

    You are most welcome!

    We would really appreciate it if you could take a minute and post a review here. This will help us to continue offering a top-notch product to users.
    Thanks!

    Thread Starter Vicky

    (@vickymedrano)

    Of course! I already rated it a well deserved 5 stars!
    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘maintenance.php being cached’ is closed to new replies.