File tree 1 file changed +11
-0
lines changed
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,17 @@ func (h *Handler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
205
205
case reqFile == "bin" || strings .HasPrefix (reqFile , "bin/" ):
206
206
h .handler .ServeHTTP (rw , r )
207
207
return
208
+ // If requesting assets, serve straight up with caching.
209
+ case reqFile == "assets" || strings .HasPrefix (reqFile , "assets/" ):
210
+ // It could make sense to cache 404s, but the problem is that during an
211
+ // upgrade a load balance may route partially to the old server, and that
212
+ // would make new asset paths get cached as 404s and not load even once the
213
+ // new server was in place. To combat that, only cache if we have the file.
214
+ if h .exists (reqFile ) && ShouldCacheFile (reqFile ) {
215
+ rw .Header ().Add ("Cache-Control" , "public, max-age=31536000, immutable" )
216
+ }
217
+ h .handler .ServeHTTP (rw , r )
218
+ return
208
219
// If the original file path exists we serve it.
209
220
case h .exists (reqFile ):
210
221
if ShouldCacheFile (reqFile ) {
You can’t perform that action at this time.
0 commit comments