Skip to content

fix(vercel): let browsers and Cloudflare cache docs images - #4927

Merged
thetaPC merged 1 commit into
mainfrom
cache-demo-images
Dec 2, 2026
Merged

thetaPC merged 1 commit into
mainfrom
cache-demo-images

Conversation

@thetaPC

@thetaPC thetaPC commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Issue

Most requests to the docs aren't page views. On 12-02, two placeholder images drew ~9,440/min (thumbnail.svg) and ~1,560/min (avatar.svg). Our code samples use their full ionicframework.com URL (85 and 143 files), so apps built from copied samples fetch them on every load.

Vercel serves every docs file with max-age=0, must-revalidate, so Cloudflare caches none of it and passes every request through. That volume trips Vercel's DDoS protection, which then shows the "Failed to verify your browser" page to all docs visitors.

Changes

  • Serve /docs/img/* with Cache-Control: public, max-age=86400, so Cloudflare and browsers keep images for a day

How to test

Run against this PR's preview URL:

curl -sI https://ionic-docs-git-cache-demo-images-ionic1.vercel.app/docs/img/demos/thumbnail.svg | grep -i cache-control

It should print cache-control: public, max-age=86400.

`curl -sI https://ionic-docs-ionic1.vercel.app/docs/img/demos/thumbnail.svg | grep -i cache-control

On main's deployment, https://ionic-docs-ionic1.vercel.app/docs/img/demos/thumbnail.svg, it prints public, max-age=0, must-revalidate. Don't compare against ionicframework.com while it's challenged: it returns the challenge page, which is private, no-store.

@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ionic-docs Ready Ready Preview Dec 2, 2026 6:59pm UTC

Request Review

@thetaPC
thetaPC marked this pull request as ready for review December 2, 2026 19:10
@thetaPC
thetaPC requested a review from a team as a code owner December 2, 2026 19:10
@thetaPC
thetaPC requested a review from ShaneK December 2, 2026 19:10
@thetaPC
thetaPC merged commit e43bec7 into main Dec 2, 2026
7 checks passed
@thetaPC
thetaPC deleted the cache-demo-images branch December 2, 2026 19:11

This branch was successfully deployed

1 active deployment
Preview — 8450e842 Deployed Dec 2, 2026 by vercel[bot]
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.

2 participants