Search
Star
Feedback
Setup for Free
© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
Caching & TOO_MANY_REDIRECTS on Next.js project deployed with Cloudflare Pages - Cloudflare Developers
CD
Cloudflare Developers
•
6mo ago
•
1 reply
udidu
Caching & TOO_MANY_REDIRECTS on Next.js project deployed with Cloudflare Pages
Hi everyone
,
I
’m running a Next
.js project on Cloudflare Pages and from time to time
, after a new deployment
, I get
TOO_MANY_REDIRECTS
TOO_MANY_REDIRECTS
errors when accessing certain pages
. The issue seems to be tied to JavaScript resources
.
What I
’ve noticed
:
After deployment
, some JavaScript file hashes change
(as expected
)
.
However
, the HTML page served appears to be cached with old references to JS files that no longer exist
.
This leads to broken requests
/ redirect loops until I manually purge the cache
.
After a purge
, everything works fine
—until the next deployment
.
This makes me think the problem is related to how HTML and asset caching is configured
.
Questions
:
Is there a recommended cache configuration for Cloudflare Pages
+ Next
.js to avoid serving stale HTML that references outdated JS files
?
Should I be setting custom cache
-control headers
(e
.g
.
, no
-cache for HTML but immutable for static assets
)
?
Is there a Cloudflare Pages setting I
’m missing that handles cache invalidation automatically after deployments
?
Any guidance or examples of proper caching strategies for Next
.js on Cloudflare Pages would be super helpful
.
Thanks
!
Cloudflare Developers
Join
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Similar Threads
Was this page helpful?
Yes
No
Recent Announcements
Similar Threads
ERR_TOO_MANY_REDIRECTS on Cloudflare tunnel with Proxmox
CD
Cloudflare Developers / pages-help
2y ago
Too many subrequests with Cloudflare Pages
CD
Cloudflare Developers / pages-help
2y ago
Next.js + Cloudflare pages functions
CD
Cloudflare Developers / pages-help
13mo ago