Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
skhaz committed Nov 20, 2023
1 parent 3084fc4 commit f834459
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
width: {{.Width}}px;
height: {{.Height}}px;
display: block;
opacity: 0;
animation: fadeIn 3s ease forwards;
}

@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}

#spinner {
Expand Down
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,16 @@ func assetsHandler(static fs.FS) echo.HandlerFunc {
return fmt.Errorf("error computing SHA1: %w", err)
}

etag := fmt.Sprintf(`"%x"`, h.Sum(nil))

c.Response().Header().Set("Cache-Control", "public, max-age=31536000, s-maxage=31536000")
c.Response().Header().Set("Expires", time.Now().AddDate(1, 0, 0).Format(http.TimeFormat))
c.Response().Header().Set("ETag", etag)
etag := fmt.Sprintf("%x", h.Sum(nil))

if c.Request().Header.Get("If-None-Match") == etag {
return c.NoContent(http.StatusNotModified)
}

c.Response().Header().Set("Cache-Control", "public, max-age=31536000, s-maxage=31536000")
c.Response().Header().Set("Expires", time.Now().AddDate(1, 0, 0).Format(http.TimeFormat))
c.Response().Header().Set("ETag", etag)

c.Response().Header().Set(echo.HeaderContentType, http.DetectContentType(content))
c.Response().WriteHeader(http.StatusOK)
if _, err = c.Response().Write(content); err != nil {
Expand Down

0 comments on commit f834459

Please sign in to comment.