workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

if-none-match failing to ever match

Open GregBrimble opened this issue 3 years ago • 1 comments

There's a quirk with either Pages proper or wrangler pages dev where any request with an if-none-match header gets completely messed up.

This issue is for an investigation into the behavior and subsequent fix.

GregBrimble avatar Dec 15 '21 17:12 GregBrimble

https://github.com/remix-run/remix/blob/ca382b16223e2766fe333b22f177550d2f9070fc/packages/remix-cloudflare-pages/worker.ts#L53-L54

GregBrimble avatar Jul 06 '22 14:07 GregBrimble

Seconding, this might be the reason:

"exceptions": [
    {
      "name": "TypeError",
      "message": "ETag in HTTP header needs to be wrapped in quotes (W/\"0aswgdddom0h2pj2vefw3qvw3hvndj5f\").",
      "timestamp": 1000000000000
    }
  ],

haywirez avatar Apr 07 '23 14:04 haywirez

Can someone add a reproducible example with the issue please?

I patched Remix to comment out the line where it deletes the if-none- matches header and weak ETags seems to work fine for me https://notionicons-cloudflare-pages.pages.dev

theMosaad avatar May 27 '23 15:05 theMosaad

@GregBrimble I wonder if this could be related to your page containing an email address or http (as in, not https) url

Specifically from here: https://developers.cloudflare.com/cache/reference/etag-headers/

When using weak ETag headers, disable Email Obfuscation and Automatic HTTPS Rewrites to ensure Cloudflare does not remove the ETag headers set by your origin web server.

I have a hobby project where I saw this bug as well, however it was due to the main site's html being slightly different for every timestamp. Here's the non-repro: https://github.com/matthova/remix-cloudflare-pages-etag-repro IMO we should explore removing this line: https://github.com/remix-run/remix/blob/main/packages/remix-cloudflare-pages/worker.ts#L54

context.request.headers.delete("if-none-match");

and instead reference Cloudflare's advice related to modified etags, due to email obfuscation and https rewrites

matthova avatar Oct 15 '23 05:10 matthova

Live site here https://remix-cloudflare-pages-etag-repro.pages.dev

matthova avatar Oct 15 '23 06:10 matthova