Commit 56d2fcd2 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'mk/image-scaler-client-cache-label' into 'master'

Add success-client-cache status for image scaler

See merge request gitlab-org/gitlab-workhorse!656
parents b4e50d0f a8a34f88
---
title: 'Image scaler: add success-client-cache status label'
merge_request: 656
author:
type: fixed
......@@ -51,10 +51,11 @@ type imageFile struct {
}
const (
statusSuccess = "success" // a rescaled image was served
statusScalingFailure = "scaling-failed" // scaling failed but the original image was served
statusRequestFailure = "request-failed" // no image was served
statusUnknown = "unknown" // indicates an unhandled status case
statusSuccess = "success" // a rescaled image was served
statusClientCache = "success-client-cache" // scaling was skipped because client cache was fresh
statusScalingFailure = "scaling-failed" // scaling failed but the original image was served
statusRequestFailure = "request-failed" // no image was served
statusUnknown = "unknown" // indicates an unhandled status case
)
var envInjector = tracing.NewEnvInjector()
......@@ -197,6 +198,7 @@ func (r *Resizer) Inject(w http.ResponseWriter, req *http.Request, paramsData st
setLastModified(w, imageFile.lastModified)
// If the original file has not changed, then any cached resized versions have not changed either.
if checkNotModified(req, imageFile.lastModified) {
status = statusClientCache
logger.WithFields(*logFields(0)).Printf("ImageResizer: Use cached image")
writeNotModified(w)
return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment