Purge cache with '$_SERVER["REQUEST_URI"]'

#1
Ekran Resmi 2020-12-30 21.40.11.png

Line 1 and line 2 aren't the same?

The first line is purge the cache, but second line does not purge cache. How can I get the page address and delete the cache with php?
 

serpent_driver

Well-Known Member
#2
If a page is already cached, the output of this requested URL is static HTML and PHP can't be executed. That's why hardcoded URL in purge header works and PHP generated URL doesn't.

To get what you want to, setup a simple PHP page that purges requested URI by AJAX request (jQuery)

PHP:
<?php
$purgeUrl = $_GET['ReqUri'];
header('X-LiteSpeed-Purge:' .  $purgeUrl);
 
Last edited:
Top