Forum Replies Created

Viewing 15 replies - 16 through 30 (of 114 total)
  • Thread Starter Natalya

    (@nalitana)

    Здравствуйте! Я поторопилась с ответом. Снова появились ошибки.

    [06-Jul-2021 12:24:51 UTC] PHP Warning:  Undefined variable $user_login in /home/site.ru/wp-login.php on line 1379
    [06-Jul-2021 12:24:51 UTC] PHP Warning:  Undefined variable $error in /home/site.ru/wp-login.php on line 1401

    И еще вопрос. Я использую плагин Litespeed, добавила в исключение из оптимизации некоторые скрипты CleanTalk, только скрипт apbct-public никак не желает исключаться, только если не добавить его вместе с версией _ver=5.159.7&, которая при обновлении меняется. Не подскажите, как правильно исключить из оптимизации Litespeed данный скрипт?
    Иначе в консоли браузера будет такое уведомление:
    The resource /wp-content/plugins/cleantalk-spam-protect/js/apbct-public.min.js?apbct_ver=5.159.7& was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriateasvalue and it is preloaded intentionally.

    Thread Starter Natalya

    (@nalitana)

    Oh, I thought that was the subject of the letter. Thanks!))

    Thread Starter Natalya

    (@nalitana)

    Can you tell me where I can find your email?

    Thread Starter Natalya

    (@nalitana)

    Do you need access to the site or do you want to view it as a visitor? If as a visitor, I can send you links to the mail. If you need a site with access, then I need to register a new domain, since this hosting does not provide a test domain, but I will do this tomorrow, since today we already have 5 in the morning.))

    Thread Starter Natalya

    (@nalitana)

    Friends, I just disabled the LS plugin on one site and 304 Not Modified immediately started working. (screenshot of the site without the plugin) Whereas on the second site with the plugin enabled, the test result is negative. (screenshot of the website with the plugin). I’m sorry that I’m sending you screenshots in Russian, since I didn’t find a similar testing tool, but the response code is specified in English.

    Thread Starter Natalya

    (@nalitana)

    Hi! I can’t provide you with a test site on this server yet. Most likely, I will buy a new domain and create a new website, but for this I need some time. Have you tested without the LS plugin? It may be possible to try to disable file compression in CPANEL, sometimes “-gzip” or “- br” can be added to the contents of the “Last-Modified” and “ETag”headers. Also try creating an empty file in the root folder test.php and insert 1 version of the php code into it. Open it in the browser and check the headers of this page, do not forget to remove the check mark from the “Disable cache”item in the developer tools. I read somewhere that the “Content-Length” header should also be present.

    Also, please pay attention to the Litespeed documentation, it just talks about 304 Not Modified. Just how to make it work?

    Thread Starter Natalya

    (@nalitana)

    Maybe I misunderstood, but it says here that the Litespeed server sets the response header “Last-Modified” – litespeedtech.com. Then where is “If-Modified-Since”…

    Thread Starter Natalya

    (@nalitana)

    Before writing to you, I turned to my hosting with a question about how to enable “If-Modified-Since”. They provided me with this code that needs to be inserted into header.php before the html tag.

    <?php
    $LastModified_unix = strtotime(date("D, d M Y H:i:s", filectime($_SERVER['SCRIPT_FILENAME'])));
    $LastModified = gmdate("D, d M Y H:i:s \G\M\T", $LastModified_unix);
    $IfModifiedSince = false;
    
    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);
    ?>
    

    In addition, there is another way, this code must be inserted into the file .htaccess.

    RewriteEngine on
    RewriteRule .* - [E=HTTP_IF_MODIFIED_SINCE:%{HTTP:If-Modified-Since}]
    RewriteRule .* - [E=HTTP_IF_NONE_MATCH:%{HTTP:If-None-Match}]

    When I told them that this method does not work for me, they said that they installed a clean WP on their test site, inserted 1 version of the code and everything worked for them. After that, they advised me to contact the developers.

    You can test both methods. Also for testing, please pay attention to the plugin Cache-Enabler, it has support for 304 Not Modified.

    Thread Starter Natalya

    (@nalitana)

    Yes, by default, WP does not include various headers. So I added the above code, which adds the If-Modified-Since and Last-Modified headers. Before switching to the server with Litespeed, I used the “Cache Enabler” plugin, and it automatically added these headers. It would be great if it was possible and Litespeed, as this speeds up the indexing of new pages, and also reduces the load on the server because Google, Yandex, Bing will get a response 304 unmodified pages and they do not need to re-scan the page.

    Thread Starter Natalya

    (@nalitana)

    Sorry, I use a translator to communicate. Perhaps you didn’t understand me. I will try to explain the situation.

    I need the server response to be 304 if the resource has not been changed.
    If we checking the site for the Last-Modified header on the resource https://last-modified.com/en, it informs us that the site gave the time of the last modification, but did not respond to “If-Modified-Since”.

    Since it is not yet possible to enable the “If-Modified-Since” header in the Litespeed plugin, I added the following code manually:

    <?php
    $LastModified_unix = strtotime(date("D, d M Y H:i:s", filectime($_SERVER['SCRIPT_FILENAME'])));
    $LastModified = gmdate("D, d M Y H:i:s \G\M\T", $LastModified_unix);
    $IfModifiedSince = false;
    
    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);
    ?>

    After that, we test the site again, but the result has not changed. The pages will still be without “If-Modified-Since” and the server response code will be 200, despite the fact that the time of the Last-Modified has not changed.

    This is probably because the “Last-Modified” header on the page is generated by the Litespeed plugin, and not by the server, so the server cannot give the “If-Modified-Since” header.

    Thread Starter Natalya

    (@nalitana)

    Пока ошибок нет. Большое спасибо за быстрое решение!

    Thread Starter Natalya

    (@nalitana)

    Спасибо! Я пока временно деактивировала плагин.

    Thread Starter Natalya

    (@nalitana)

    1. Версия PHP 8
    2. WordPress 5.7.2
    3. Security by CleanTalk версия 5.159.7.

    Thread Starter Natalya

    (@nalitana)

    It seems to me that this is an important point for everyone who uses “Last-Modified” and “If-Modified-Since”. It is necessary that the page response is 304 for unchanged pages, but with the Litespeed plugin, the server response is always 200. Google also recommends using the “Last-Modified” and “If-Modified-Since” headers. Therefore, I would like to understand why the plugin removes “If-Modified-Since”, what changes the server response code and how to fix it?

    Thread Starter Natalya

    (@nalitana)

    Hi, @tenkstars. Then I have a question. When I enable “If-Modified-Since” via .htaccess, the page code is still 200. Does the Lightspeed plugin affect the fact that the server cannot respond with ” 304 Not Modified”?

Viewing 15 replies - 16 through 30 (of 114 total)