@@ -131,10 +131,6 @@ const nextConfig: NextConfig = {
131131 key : 'Vary' ,
132132 value : 'Accept-Encoding' ,
133133 } ,
134- {
135- key : 'Cache-Tag' ,
136- value : 'static' ,
137- } ,
138134 ] ,
139135 } ,
140136
@@ -152,86 +148,32 @@ const nextConfig: NextConfig = {
152148 key : 'CDN-Cache-Control' ,
153149 value : isProd ? 'public, max-age=2592000, immutable' : 'no-cache' ,
154150 } ,
155- {
156- key : 'Cache-Tag' ,
157- value : 'media' ,
158- } ,
159151 ] ,
160152 } ,
161153
162- // HOMEPAGE : No caching to ensure auth state is always fresh
154+ // ALL DYNAMIC PAGES : No caching to prevent stale data
163155 {
164- source : '/' ,
156+ source : '/((?!_next|api).*) ' ,
165157 headers : [
166158 {
167159 key : 'Cache-Control' ,
168- value : 'no-cache, no-store, must-revalidate' ,
160+ value : 'no-cache, no-store, must-revalidate, max-age=0 ' ,
169161 } ,
170162 {
171163 key : 'CDN-Cache-Control' ,
172- value : 'no-cache' ,
164+ value : 'no-cache, no-store, must-revalidate ' ,
173165 } ,
174166 {
175167 key : 'Pragma' ,
176168 value : 'no-cache' ,
177169 } ,
178170 {
179- key : 'Vary' ,
180- value : 'Cookie, Accept-Encoding' ,
181- } ,
182- {
183- key : 'X-Build-ID' ,
184- value : buildId ,
185- } ,
186- ] ,
187- } ,
188-
189- // DYNAMIC CONTENT: Dynamic pages (events, hackathons, etc.)
190- {
191- source : '/(hackathons|events|leaderboard|opportunities)/:path*' ,
192- headers : [
193- {
194- key : 'Cache-Control' ,
195- value : isDev
196- ? 'no-cache, no-store, must-revalidate'
197- : 'public, max-age=60, stale-while-revalidate=300' , // 1min cache, 5min SWR
198- } ,
199- {
200- key : 'CDN-Cache-Control' ,
201- value : isProd ? 'public, max-age=60, stale-while-revalidate=300' : 'no-cache' ,
202- } ,
203- {
204- key : 'X-Build-ID' ,
205- value : buildId ,
206- } ,
207- {
208- key : 'Cache-Tag' ,
209- value : 'content' ,
171+ key : 'Expires' ,
172+ value : '0' ,
210173 } ,
211174 {
212175 key : 'Vary' ,
213- value : 'Cookie, Accept-Encoding' ,
214- } ,
215- ] ,
216- } ,
217-
218- // DATABASE QUERIES: API routes that query database
219- {
220- source : '/api/(hackathons|leaderboard|tests|verify-certificate)/:path*' ,
221- headers : [
222- {
223- key : 'Cache-Control' ,
224- value : isDev
225- ? 'no-cache, no-store, must-revalidate'
226- : 'public, max-age=300, stale-while-revalidate=600' , // 5min cache, 10min SWR
227- } ,
228- {
229- key : 'CDN-Cache-Control' ,
230- value : isProd ? 'public, max-age=300, stale-while-revalidate=600' : 'no-cache' ,
231- } ,
232- {
233- key : 'Cache-Tag' ,
234- value : 'api' ,
176+ value : 'Cookie, Accept-Encoding, Authorization' ,
235177 } ,
236178 {
237179 key : 'X-Build-ID' ,
@@ -240,56 +182,30 @@ const nextConfig: NextConfig = {
240182 ] ,
241183 } ,
242184
243- // USER PRIVATE: Auth and user-specific routes
185+ // API ROUTES: No caching for dynamic data
244186 {
245- source : '/(protected|admin|profile|dashboard|auth) /:path*' ,
187+ source : '/api /:path*' ,
246188 headers : [
247189 {
248190 key : 'Cache-Control' ,
249- value : 'private, no-cache, no-store, must-revalidate' ,
191+ value : 'no-cache, no-store, must-revalidate, max-age=0 ' ,
250192 } ,
251193 {
252194 key : 'CDN-Cache-Control' ,
253- value : 'no-cache' ,
195+ value : 'no-cache, no-store, must-revalidate ' ,
254196 } ,
255197 {
256198 key : 'Pragma' ,
257199 value : 'no-cache' ,
258200 } ,
259- ] ,
260- } ,
261-
262- // API STANDARD: General API routes and public pages
263- {
264- source : '/((?!_next|protected|admin|profile|dashboard|auth).*)' ,
265- headers : [
266- {
267- key : 'Cache-Control' ,
268- value : isDev
269- ? 'no-cache, no-store, must-revalidate'
270- : 'public, max-age=0, must-revalidate' , // Always revalidate HTML
271- } ,
272- {
273- key : 'CDN-Cache-Control' ,
274- value : isProd ? 'public, max-age=60, stale-while-revalidate=300' : 'no-cache' ,
275- } ,
276201 {
277- key : 'Cache-Tag' ,
278- value : 'pages' ,
279- } ,
280- {
281- key : 'X-Build-ID' ,
282- value : buildId ,
202+ key : 'Expires' ,
203+ value : '0' ,
283204 } ,
284205 {
285206 key : 'Vary' ,
286- value : 'Cookie, Accept-Encoding' ,
207+ value : 'Cookie, Accept-Encoding, Authorization ' ,
287208 } ,
288- // Security headers
289- { key : 'X-Content-Type-Options' , value : 'nosniff' } ,
290- { key : 'X-Frame-Options' , value : 'DENY' } ,
291- { key : 'X-XSS-Protection' , value : '1; mode=block' } ,
292- { key : 'Referrer-Policy' , value : 'origin-when-cross-origin' } ,
293209 ] ,
294210 } ,
295211 ]
0 commit comments