webp-sh / webp_server_go

Go version of WebP Server. A tool that will serve your JPG/PNG/BMP/SVGs as WebP/AVIF format with compression, on-the-fly.
https://docs.webp.sh
GNU General Public License v3.0
1.79k stars 174 forks source link

fix: incorrect cache key #286

Closed HolgerHuo closed 10 months ago

HolgerHuo commented 10 months ago

In https://github.com/webp-sh/webp_server_go/commit/4003b030229327561b54fc26bf6fd1f72086681e, we deprecated ProxyMode switch, making this condition unavailable. We can simply detect proxy usage by the etag variable passed in.

n0vad3v commented 10 months ago

Proxymode is still available on configuration load, there is a function called switchProxyMode inside LoadConfig.

func switchProxyMode() {
    matched, _ := regexp.MatchString(HttpRegexp, Config.ImgPath)
    if matched {
        // Enable proxy based on ImgPath should be deprecated in future versions
        log.Warn("Enable proxy based on ImgPath will be deprecated in future versions. Use IMG_MAP config options instead")
        ProxyMode = true
    }
}
HolgerHuo commented 10 months ago

Yes, but only IMG_PATH is used to turn on s ProxyMode. If we write proxy backends in multipath style, the switch won't work anymore.

n0vad3v commented 10 months ago

Oh, I got you, yes it's indeed a problem here, merging this PR now, thanks for you contribution!