GH-13570 Allow /static/plugins/* endpoint responses to be cached (except for 404s) (#13592)
* Reinstate caching on /static/plugins/* endpoint except for 404s * fix struct name and change default behavior for staticFilesHandler
Этот коммит содержится в:
коммит произвёл
Jesse Hallam
родитель
d30f904de9
Коммит
7f6074b300
@@ -184,7 +184,7 @@ func TestStaticFilesRequest(t *testing.T) {
|
||||
th.Web.MainRouter.ServeHTTP(res, req)
|
||||
assert.Equal(t, http.StatusOK, res.Code)
|
||||
assert.Equal(t, mainJS, res.Body.String())
|
||||
assert.Equal(t, []string{"no-cache, public"}, res.Result().Header[http.CanonicalHeaderKey("Cache-Control")])
|
||||
assert.Equal(t, []string{"max-age=31556926, public"}, res.Result().Header[http.CanonicalHeaderKey("Cache-Control")])
|
||||
|
||||
// Verify cached access to the bundle with an If-Modified-Since timestamp in the future
|
||||
future := time.Now().Add(24 * time.Hour)
|
||||
@@ -194,7 +194,7 @@ func TestStaticFilesRequest(t *testing.T) {
|
||||
th.Web.MainRouter.ServeHTTP(res, req)
|
||||
assert.Equal(t, http.StatusNotModified, res.Code)
|
||||
assert.Empty(t, res.Body.String())
|
||||
assert.Equal(t, []string{"no-cache, public"}, res.Result().Header[http.CanonicalHeaderKey("Cache-Control")])
|
||||
assert.Equal(t, []string{"max-age=31556926, public"}, res.Result().Header[http.CanonicalHeaderKey("Cache-Control")])
|
||||
|
||||
// Verify access to the bundle with an If-Modified-Since timestamp in the past
|
||||
past := time.Now().Add(-24 * time.Hour)
|
||||
@@ -204,7 +204,7 @@ func TestStaticFilesRequest(t *testing.T) {
|
||||
th.Web.MainRouter.ServeHTTP(res, req)
|
||||
assert.Equal(t, http.StatusOK, res.Code)
|
||||
assert.Equal(t, mainJS, res.Body.String())
|
||||
assert.Equal(t, []string{"no-cache, public"}, res.Result().Header[http.CanonicalHeaderKey("Cache-Control")])
|
||||
assert.Equal(t, []string{"max-age=31556926, public"}, res.Result().Header[http.CanonicalHeaderKey("Cache-Control")])
|
||||
|
||||
// Verify handling of 404.
|
||||
req, _ = http.NewRequest("GET", "/static/plugins/com.mattermost.sample/404.js", nil)
|
||||
|
||||
Ссылка в новой задаче
Block a user