Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

110
Visualizações
HTTP-caching long search requests?

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

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda