If-Modified-Since header does not works

It does not reseive 304 code. I check it on https://last-modified.com/en/ and https://bertal.ru/index.php?a6[...]i.org/doc/HomePage#h .
In my istallation R5.5.10 I fix it by inserting php code provided on Last-Modified.com to first line of \theme\_common\_header.php
Probably there is more beautiful solution.

Files

403_network_analysis_2.png 34.6 KiB  09.06.2019 18:37 
403_network_analysis.png 39.5 KiB  09.06.2019 18:30 

Comments

  1. If-Modified-Since header does work

    Just check the results in the Web developer tools -> Network analysis of your browser. There you can see the correct results.

    Loged in

    Guest


    Please read the http class for more details, see function check_http_request().

    Can't say why the mentioned service don't recognize it.

    In the http class there is the comment:
    if ($_SERVER['REQUEST_METHOD'] == 'GET')  // may be we need HEAD support ???	

    Do we need HEAD support?

    9.4 HEAD

    The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The metainformation contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information sent in response to a GET request. This method can be used for obtaining metainformation about the entity implied by the request without transferring the entity-body itself. This method is often used for testing hypertext links for validity, accessibility, and recent modification.

    The response to a HEAD request MAY be cacheable in the sense that the information contained in the response MAY be used to update a previously cached entity from that resource. If the new field values indicate that the cached entity differs from the current entity (as would be indicated by a change in Content-Length, Content-MD5, ETag or Last-Modified), then the cache MUST treat the cache entry as stale.


    Patch for HEAD support: revision:441dadd
    diff --git a/wacko/class/http.php b/wacko/class/http.php
    --- a/wacko/class/http.php
    +++ b/wacko/class/http.php
    @@ -191,7 +191,7 @@
     				$lastm = substr($lastm, 0, $p);
     			}
     
    -			if ($_SERVER['REQUEST_METHOD'] == 'GET') // may be we need HEAD support ???
    +			if ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD')
     			{
     				if (!$lastm && !$etag);
     				else if ($lastm && $gmt != $lastm);	


    But we can't send body for HEAD requests -> Apache will do all the heavy lifting (stripping the response body).
    https://developer.mozilla.org/[...]eb/HTTP/Methods/HEAD
    • WikiAdmin
    • 12.09.2019 10:30 edited
  2. 304 code response delay

    In the run function there is the following line
    if (!$user && $this->page['modified'])
    {
    	header('Last-Modified: ' . Ut::http_date(strtotime($this->page['modified']) + 120));
    }	


    which causes the 304 code response delay, I'm currently not sure which purpose that delay serves exactly.


    https://redbot.org/
    PATCH: 5b8f3a3
    • WikiAdmin
    • 25.04.2024 16:59 edited
Log in or create an account to post a comment.