Skip to content

Cache hashed assets and keep the render check current - #204

Merged
shigahi merged 2 commits into
masterfrom
asset-caching-and-current-compat-date
Nov 19, 2026
Merged

shigahi merged 2 commits into
masterfrom
asset-caching-and-current-compat-date

Conversation

@shigahi

@shigahi shigahi commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Findings from a review against the updated Cloudflare skills (Workers best practices, Wrangler, web performance). src/code.ts is unchanged, so generated scripts stay the same.

Site (public/_headers)

  • Cache /assets/* for a year as immutable. Workers serves static assets with max-age=0, must-revalidate by default, so every repeat visit revalidated the 567 kB script, the stylesheet and the preloaded font (five 304 responses per page view on production). Vite content-hashes these files, and this is the rule the static assets docs recommend.
  • Cache /fonts/* for 30 days. The font keeps its URL, so it is not marked immutable.
  • Send X-Robots-Tag: noindex on *.*.workers.dev. The site is also reachable on its workers.dev URL and on every version preview URL.

The rules also apply to 404 responses: a request for a missing file under /assets/ gets the one-year header too. This is only reachable while a deployment propagates, and the next build changes the file name.

Render check (scripts/render-check.mjs)

  • Run the generated worker on today's compatibility date instead of 2026-03-11. A Worker created in the dashboard gets the current date, so the daily check now covers the runtime new users get (for example nodejs_compat, on by default since 2026-08-04). Wrangler falls back to the newest date its runtime supports.
  • Use a 6000px-tall viewport. Notion now only renders the blocks near the viewport, and drops them again when they scroll away. With the 1000px viewport the database views, the rows and the subpage link were missing on notion.site as well, so four checks have reported NOTION for weeks, and FAIL when only the notion.site session happened to get the whole page.

Not changed:

  • wrangler.jsonc: the site Worker has no script, so traces and a newer compatibility date would have no effect.
  • The generated worker buffers /api/* request bodies to rewrite them. A size limit would not stop a flood of smaller requests, so this is left to Cloudflare rate limiting rules.

Verification

  • npm test: 26 tests pass. npm run build passes.
  • wrangler dev on the build: /assets/*.js and /assets/*.css return max-age=31536000, immutable, the font max-age=2592000, HTML and other files the default. X-Robots-Tag is only sent when the Host is a workers.dev name, not for worknot.classmethod.live.
  • npm run check:render against live Notion: every check passes on both targets (embeds are skipped, as before). On master the same run reported FAIL for database views and navigation.
  • Probed the test page on notion.site and on sensitive-information.classmethod.live with both viewport sizes, three loads each: at 1000px no database view is in the DOM until the page is scrolled, at 6000px all six views, the rows, both images and the PDF and file blocks are there.

After merge

  • Deploy the site to apply the headers.
  • Redeploy sensitive-information with the current compatibility date and traces enabled.

shigahi and others added 2 commits November 19, 2026 11:55
Workers serves static assets with max-age=0, must-revalidate, so every
repeat visit revalidated the 567 kB script, the stylesheet and the
preloaded font. Vite content-hashes the files in /assets/, so cache
them for a year as immutable. The font keeps its URL, so cache it for
30 days.

Also send X-Robots-Tag: noindex on workers.dev hosts (the production
workers.dev URL and the version preview URLs), so that only
worknot.classmethod.live is indexed.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…e viewport

A Worker created in the dashboard gets the current compatibility date,
but the check ran the generated worker on 2026-03-11. Use today's date,
so that the daily check covers the runtime new users get, such as
nodejs_compat being on by default since 2026-08-04.

Notion now only renders the blocks near the viewport. With a 1000px
viewport the database views, the rows and the subpage link were
missing, on notion.site as well, so those checks reported NOTION, or
FAIL when only the notion.site session got the whole page. Use a
viewport taller than the test page.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@shigahi
shigahi merged commit bdb808e into master Nov 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant