Revert ETag change
This commit is contained in:
parent
4175c4e31e
commit
97e73d6174
1 changed files with 2 additions and 22 deletions
24
main.go
24
main.go
|
@ -64,28 +64,8 @@ func main() {
|
||||||
deploymentTime := fmt.Sprintf("%d", time.Now().UnixNano())
|
deploymentTime := fmt.Sprintf("%d", time.Now().UnixNano())
|
||||||
|
|
||||||
// Static server
|
// Static server
|
||||||
fs := http.FS(PublicFS)
|
fs := http.FS(PublicFS)
|
||||||
e.GET("/public/*", func(c echo.Context) error {
|
e.GET("/public/*", echo.WrapHandler(http.FileServer(fs)))
|
||||||
// Generate an ETag based on the deployment time
|
|
||||||
eTag := fmt.Sprintf(`W/"%s"`, deploymentTime)
|
|
||||||
|
|
||||||
// Set the ETag header
|
|
||||||
c.Response().Header().Set("ETag", eTag)
|
|
||||||
|
|
||||||
// Set the Cache-Control header
|
|
||||||
c.Response().Header().Set("Cache-Control", "public, max-age=3600")
|
|
||||||
|
|
||||||
// Check the file extension and set the Content-Type header accordingly
|
|
||||||
ext := filepath.Ext(c.Param("*"))
|
|
||||||
switch ext {
|
|
||||||
case ".css":
|
|
||||||
c.Response().Header().Set("Content-Type", "text/css; charset=utf-8")
|
|
||||||
case ".js":
|
|
||||||
c.Response().Header().Set("Content-Type", "application/javascript; charset=utf-8")
|
|
||||||
}
|
|
||||||
|
|
||||||
return echo.WrapHandler(http.FileServer(fs))(c)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Page routes
|
// Page routes
|
||||||
e.GET("/", pages.Home)
|
e.GET("/", pages.Home)
|
||||||
|
|
Loading…
Add table
Reference in a new issue