N
N
nalitana2021-06-24 19:13:53
LiteSpeed ​​Web Server
nalitana, 2021-06-24 19:13:53

Why does If-Modified-Since not work with Litespeed WordPress plugin and response code is always 200?

Hello! The LiteSpeed ​​plugin is installed on WordPess, the hosting also works on LiteSpeed.
Added code:

<?php
$LastModified_unix = 1594844676;
$LastModified = gmdate("D, d M Y H:i:s \G\M\T", $LastModified_unix);
$IfModifiedSince = gmdate("D, d M Y H:i:s \G\M\T", $LastModified_unix);
if (isset($_ENV['HTTP_IF_MODIFIED_SINCE']))
    $IfModifiedSince = strtotime(substr($_ENV['HTTP_IF_MODIFIED_SINCE'], 5)); 
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']))
    $IfModifiedSince = strtotime(substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 5));
if ($IfModifiedSince && $IfModifiedSince >= $LastModified_unix) {
    header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
    exit;
}
header('Last-Modified: '. $LastModified);
header('If-Modified-Since: '. $IfModifiedSince);

?>


The problem is that the If-Modified-Since header does not work and the server response code for pages is always 200, not 304. If the plugin is disabled, then If-Modified-Since is displayed normally and the response code is 304.

I also tried the Cache Enable plugin from Key CDN, it automatically adds the “Last-Modified” and “If-Modified-Since” headers, but for some reason this did not work on this hosting either.

Can you please tell me why when the LiteSpeed ​​plugin is enabled, the "If-Modified-Since" header does not work and the server response code is always 200?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question