I seek for a solution to request a resource identified by possibly a long string (>8k) and let browser/proxy cache the response.
It is a Chrome-extension javascript fetch() search request (thus being of unknown contents and length) that I would like to retrieve from cache next time. The same request will always yield the same response.
I know I can take care and store data in browser storage myself... but I am interested if I can do it code-less leveraging standard HTTP caching that will work also with any proxy.
The initial idea was to have a GET request with the BODY part containing a request (RFC is quite unclear and recently changed) where the URL will contain SHA1 of the BODY so next time the resource can be retrieved from cache as any normal resource. But fetch() does not allow for that and compatibility with other software is questionable.
Simply: is there a way that would achieve the following?
let body = JSON.stringify({...request});
fetch("https://example.org/search?sha1=" + sha1(body), {
"method": "GET",
"body": body,
"headers": {"Content-Type": "application/json"},
"cache": "force-cache"
})
Note: Fetch does not allow for GET/HEAD with the body.
I need a solution that will work with the following technologies: Chrome, Apache, NGINX, Cloudflare
Note: I am aware of fetch() interception: https://developers.cloudflare.com/workers/examples/cache-post-request