Skip to content
This repository has been archived by the owner on Apr 5, 2019. It is now read-only.

Requesting static assets should return 304 #193

Open
JonTheNiceGuy opened this issue Oct 15, 2013 · 2 comments
Open

Requesting static assets should return 304 #193

JonTheNiceGuy opened this issue Oct 15, 2013 · 2 comments

Comments

@JonTheNiceGuy
Copy link
Member

Example: requests for assets such as jquery return HTTP200 then content.

Desired behaviour, first pass returns 200, then subsequent returns 304.

Workaround by removing htaccess content!

@JonTheNiceGuy
Copy link
Member Author

Add this code (and make it fit) from https://github.com/CampFireManager/cfm2/blob/master/classes/Base/Response.php#L215:

    $objRequest = Container_Request::getRequest();
    $thisetag = sha1($objRequest->get_requestUrlExParams() . $body);
    header("Last-Modified: " . gmdate("D, d M Y H:i:s", self::getLastModified()) . " GMT");
    header("ETag: \"$thisetag\"");
    $arrETag = $objRequest->get_hasIfNoneMatch();
    if (is_array($arrETag)) {
        foreach ($arrETag as $etag) {
            if ($thisetag == $etag || 'W/ ' . $thisetag == $etag) {
                header('HTTP/1.1 304 ' . static::$httpStatusCodes[304]);
                exit(0);
            }
        }
    }

Add it to https://github.com/CampFireManager/cfm2/blob/master/classes/Base/Response.php#L286

@JonTheNiceGuy
Copy link
Member Author

Work-around implemented (with a variety of methods - not all of them working, mind!) in PR #197

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant