- Aug 2023
-
datatracker.ietf.org datatracker.ietf.org
Tags
- http:header=if-none-match
- http:header=cache-control:must-understand
- http:header=pragma
- http:header=cache-control:no-transform
- http:header=cache-control:public
- http:header=cache-control:private
- http:header=warning
- http:header=if-modified-since
- http:header=cache-control
- http:header=if-match
- http:header=cache-control:s-maxage
- http:header=age
- wikipedia:en=HTTP_caching
- http:header=if-unmodified-since
- http:header=cache-control:max-stale
- http:header=cache-control:no-cache
- http:header=cache-control:min-fresh
- http:code=206
- http:header=cache-control:no-store
- http:header=cache-control:must-revalidate
- caching
- http:header=expires
- http:code=304
- http:header=if-range
- http:header=cache-control:proxy-revalidate
- http
- http:header=cache-control:only-if-cached
- urn:ietf:rfc:9111
- http:header=cache-control:max-age
Annotators
URL
-
- May 2023
-
www.bortzmeyer.org www.bortzmeyer.org
-
datatracker.ietf.org datatracker.ietf.org
-
stackoverflow.com stackoverflow.com
- Mar 2023
-
sergiodxa.com sergiodxa.com
-
Send the 304 Not Modified response
```js import etag from "etag"; import { renderToString } from "react-dom/server"; import type { EntryContext, HandleDataRequestFunction } from "remix"; import { RemixServer } from "remix";
export default function handleRequest( request: Request, status: number, headers: Headers, remixContext: EntryContext ) { let markup = renderToString( <RemixServer context={remixContext} url={request.url} /> );
headers.set("Content-Type", "text/html"); headers.set("ETag", etag(markup));
// check if the
If-None-Match
header matches the ETag if (request.headers.get("If-None-Match") === headers.get("ETag")) { // and send an empty Response with status 304 and the headers. return new Response("", { status: 304, headers }); }return new Response("<!DOCTYPE html>" + markup, { status, headers }); }
export let handleDataRequest: HandleDataRequestFunction = async ( response: Response, { request } ) => { let body = await response.text();
if (request.method.toLowerCase() === "get") { response.headers.set("etag", etag(body)); // As with document requests, check the
If-None-Match
header // and compare it with the Etag, if they match, send the empty 304 Response if (request.headers.get("If-None-Match") === response.headers.get("ETag")) { return new Response("", { status: 304, headers: response.headers }); } }return response; }; ```
-
-
developer.mozilla.org developer.mozilla.orgETag1