Browse Source

Use unique file names for cache busting instead of query string

Frédéric Guillot 4 năm trước cách đây
mục cha
commit
897cd7cb34
2 tập tin đã thay đổi với 5 bổ sung5 xóa
  1. 3 3
      template/templates/common/layout.html
  2. 2 2
      ui/ui.go

+ 3 - 3
template/templates/common/layout.html

@@ -30,7 +30,7 @@
     <link rel="apple-touch-icon" sizes="180x180" href="{{ route "appIcon" "filename" "icon-180.png" }}">
     <link rel="apple-touch-icon" sizes="180x180" href="{{ route "appIcon" "filename" "icon-180.png" }}">
 
 
     <meta name="theme-color" content="{{ theme_color .theme }}">
     <meta name="theme-color" content="{{ theme_color .theme }}">
-    <link rel="stylesheet" type="text/css" href="{{ route "stylesheet" "name" .theme }}?{{ .theme_checksum }}">
+    <link rel="stylesheet" type="text/css" href="{{ route "stylesheet" "name" .theme "checksum" .theme_checksum }}">
 
 
     {{ if and .user .user.Stylesheet }}
     {{ if and .user .user.Stylesheet }}
     {{ $stylesheetNonce := nonce }}
     {{ $stylesheetNonce := nonce }}
@@ -40,8 +40,8 @@
     <meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src * data:; media-src *; frame-src *">
     <meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src * data:; media-src *; frame-src *">
     {{ end }}
     {{ end }}
 
 
-    <script src="{{ route "javascript" "name" "app" }}?{{ .app_js_checksum }}" defer></script>
-    <script src="{{ route "javascript" "name" "service-worker" }}?{{ .sw_js_checksum }}" defer id="service-worker-script"></script>
+    <script src="{{ route "javascript" "name" "app" "checksum" .app_js_checksum }}" defer></script>
+    <script src="{{ route "javascript" "name" "service-worker" "checksum" .sw_js_checksum }}" defer id="service-worker-script"></script>
 </head>
 </head>
 <body
 <body
     {{ if .csrf }}data-csrf-token="{{ .csrf }}"{{ end }}
     {{ if .csrf }}data-csrf-token="{{ .csrf }}"{{ end }}

+ 2 - 2
ui/ui.go

@@ -37,8 +37,8 @@ func Serve(router *mux.Router, store *storage.Storage, pool *worker.Pool) {
 	uiRouter.StrictSlash(true)
 	uiRouter.StrictSlash(true)
 
 
 	// Static assets.
 	// Static assets.
-	uiRouter.HandleFunc("/stylesheets/{name}.css", handler.showStylesheet).Name("stylesheet").Methods(http.MethodGet)
-	uiRouter.HandleFunc("/{name}.js", handler.showJavascript).Name("javascript").Methods(http.MethodGet)
+	uiRouter.HandleFunc("/stylesheets/{name}.{checksum}.css", handler.showStylesheet).Name("stylesheet").Methods(http.MethodGet)
+	uiRouter.HandleFunc("/{name}.{checksum}.js", handler.showJavascript).Name("javascript").Methods(http.MethodGet)
 	uiRouter.HandleFunc("/favicon.ico", handler.showFavicon).Name("favicon").Methods(http.MethodGet)
 	uiRouter.HandleFunc("/favicon.ico", handler.showFavicon).Name("favicon").Methods(http.MethodGet)
 	uiRouter.HandleFunc("/icon/{filename}", handler.showAppIcon).Name("appIcon").Methods(http.MethodGet)
 	uiRouter.HandleFunc("/icon/{filename}", handler.showAppIcon).Name("appIcon").Methods(http.MethodGet)
 	uiRouter.HandleFunc("/manifest.json", handler.showWebManifest).Name("webManifest").Methods(http.MethodGet)
 	uiRouter.HandleFunc("/manifest.json", handler.showWebManifest).Name("webManifest").Methods(http.MethodGet)