sending header to purge matching wildcard urls

mkaaaay

Well-Known Member
#1
Knowing that we can clear the entire cache by sending:

header('X-LiteSpeed-Purge: *');

Is it possible to purge for example, all product pages using something like below? I tried but it doesn't work and https://docs.litespeedtech.com/lscache/manualpurge/ is very limited with regard to header purging.

header('X-LiteSpeed-Purge: /products/*');

Finally, what about using the header to purge the current url only?

header('X-LiteSpeed-Purge: https://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'');

...doesn't work either
 
Last edited:

NiteWave

Administrator
#2

mkaaaay

Well-Known Member
#3
Hi, ok so sorry - I didn't see that there - the tagging accomplishes the wildcard function very well.



I have already tried:
header('X-LiteSpeed-Purge: '.$_SERVER['PHP_SELF'].'');

But it doesn't work. Possibly it worked once, but that was it. What am I missing?
 
Last edited:

NiteWave

Administrator
#4
did quick tests.
1. looks purge myself not working.
Code:
#cat p.php
<?php
header('X-LiteSpeed-Purge: '.$_SERVER['PHP_SELF']);
echo "Please purge myself\n";
this p.php page never get cached and hence, no purge since no cache.
(maybe this is a cool trick ? this is to tell web server: please don't cache myself. no need change any cache settings in other places, server configuration, virtual host configuration, .htaccess etc, just in this script)

2. however, purge other URLs is ok.

combining above 2, you can write a purge.php, which won't cache itself, and purge other URLs' cache.
 
Top