• Resolved ffenton

    (@ffenton)


    We have a large amount of dynamic data on our site. Some of this is added and amended via log in pages outside of wordpress folder.
    When an item is updated via a form, the form submits to itself and updates database. At the same time I’d like to purge the cache for the specifc page that displays this info on wordpress site.

    I’ve seen similar questions with answers linking to this page https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:developer_guide:response_headers and am assuming that I should purge by URL but don’t know how to implement it in my php code??

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support Hai Zheng⚡

    (@hailite)

    If your code is in WordPress, please call LiteSpeed_Cache_API::purge($tag)

    Ref: https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:api

    If you have specific tags served when visiting that page, you can also purge that instead of URL.

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    Trigger the following code with URL you desired to purge

    <?php
    header("X-LiteSpeed-Purge: /your-php.php");

    when you want to purge the specific page

    Best regards,

    Thread Starter ffenton

    (@ffenton)

    My code isn’t in WordPress so can’t use LiteSpeed_Cache_API::purge($tag)

    Also have a problem with using header(“X-LiteSpeed-Purge: /your-php.php”) as I get Cannot modify header information – headers already sent by etc

    To explain better I have a php file that contains a form which posts back to itself. On submitting, the form fields are used to run query to update database. Once query has run I then want to purge the corresponding page and then redisplay form with fields populated with database values.

    Plugin Support LiteSpeed Lisa

    (@lclarke)

    How urgent is it to update the page immediately? We do have a setting that will let you schedule a daily purge for a particular page. Would that be sufficient?

    It’s in the Settings > Purge tab, all the way at the bottom.

    Plugin Support Hai Zheng⚡

    (@hailite)

    http://php.net/manual/en/function.header.php

    Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP

    Thread Starter ffenton

    (@ffenton)

    We have approximately 14,000 listings which are added to/removed daily by various means. Some automated, some manual via a separate login area outside of WordPress.
    It’s the manual ones that I’m wanting to deal with at the moment. I want these to show updated information immediately.

    I know header() must be called before any actual output but the php file is an included file so not possible.

    Plugin Support Hai Zheng⚡

    (@hailite)

    Based on your requirement, the purge should be the key point to make it.

    You can try some other ways to finish the purge. E.g. if your php is included after output, you can output a iframe/ajax to call a fresh new page which only send that purge header.

    Thread Starter ffenton

    (@ffenton)

    Thank you.
    Managed to achieve it by using an iframe

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Purge cache for specific page via PHP’ is closed to new replies.