Skip to content

Commit

Permalink
web: remove dead code (#47097)
Browse files Browse the repository at this point in the history
  • Loading branch information
zmb3 authored Oct 2, 2024
1 parent ec99721 commit e8c252c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 108 deletions.
105 changes: 0 additions & 105 deletions lib/web/assets.go

This file was deleted.

6 changes: 3 additions & 3 deletions lib/web/cachehandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ package web

import (
"net/http"
"path/filepath"
"path"
"slices"
"time"

"github.com/gravitational/teleport/lib/httplib"
)

// makeCacheHandler adds support for gzip compression for given handler.
// makeCacheHandler sets cache headers for cacheable file types.
func makeCacheHandler(handler http.Handler, etag string) http.Handler {
cachedFileTypes := []string{".woff", ".woff2", ".ttf"}

return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// We can cache fonts "permanently" because we don't expect them to change. The rest of our
// assets will have an ETag associated with them (teleport version) that will allow us
// to conditionally send the updated assets or a 304 status (Not Modified) response
if slices.Contains(cachedFileTypes, filepath.Ext(r.URL.Path)) {
if slices.Contains(cachedFileTypes, path.Ext(r.URL.Path)) {
httplib.SetCacheHeaders(w.Header(), time.Hour*24*365 /* one year */)
} else {
httplib.SetEntityTagCacheHeaders(w.Header(), etag)
Expand Down

0 comments on commit e8c252c

Please sign in to comment.