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

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?


Well-Known Member
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)

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