mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-12 14:16:28 +03:00
perf: add cache headers for static assets on Cloudflare Pages
- Hashed JS/CSS bundles: immutable, 1 year cache - Images/logos/SVGs: 1 week cache with 1 day stale-while-revalidate - HTML pages: browser revalidates, CDN caches 1h - ZIP downloads: 1h cache - API routes: unchanged (CDN 24h) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
e5083bbe47
commit
af69a189e3
@@ -245,6 +245,45 @@ function generateCFConfig(buildDir) {
|
||||
X-Content-Type-Options: nosniff
|
||||
X-Frame-Options: DENY
|
||||
|
||||
# HTML pages: browser always revalidates, CDN caches 1h
|
||||
/*.html
|
||||
Cache-Control: public, max-age=0, s-maxage=3600, stale-while-revalidate=600
|
||||
|
||||
# Hashed JS/CSS bundles: immutable (filename changes on content change)
|
||||
/assets/*.js
|
||||
Cache-Control: public, max-age=31536000, immutable
|
||||
|
||||
/assets/*.css
|
||||
Cache-Control: public, max-age=31536000, immutable
|
||||
|
||||
# Static images and logos: 1 week + 1 day stale
|
||||
/assets/*.png
|
||||
Cache-Control: public, max-age=604800, stale-while-revalidate=86400
|
||||
|
||||
/assets/*.svg
|
||||
Cache-Control: public, max-age=604800, stale-while-revalidate=86400
|
||||
|
||||
/assets/*.webp
|
||||
Cache-Control: public, max-age=604800, stale-while-revalidate=86400
|
||||
|
||||
/antipattern-images/*
|
||||
Cache-Control: public, max-age=604800, stale-while-revalidate=86400
|
||||
|
||||
# Root static assets (favicon, og-image, etc.)
|
||||
/favicon.svg
|
||||
Cache-Control: public, max-age=604800, stale-while-revalidate=86400
|
||||
|
||||
/og-image.jpg
|
||||
Cache-Control: public, max-age=604800, stale-while-revalidate=86400
|
||||
|
||||
/apple-touch-icon.png
|
||||
Cache-Control: public, max-age=604800, stale-while-revalidate=86400
|
||||
|
||||
# ZIP downloads: 1h cache
|
||||
/dist/*.zip
|
||||
Cache-Control: public, max-age=3600, stale-while-revalidate=600
|
||||
|
||||
# API routes: CDN caches 24h
|
||||
/api/*
|
||||
Cache-Control: public, s-maxage=86400, stale-while-revalidate=3600
|
||||
|
||||
|
||||
Reference in New Issue
Block a user