willnorris / imageproxy

A caching, resizing image proxy written in Go
Apache License 2.0
3.55k stars 482 forks source link

Double caching? #227

Open Fieldistor opened 4 years ago

Fieldistor commented 4 years ago

When there is no any option (r.Options.String() = 0x0) it leads to double caching (no fragment cached image ({remote_url}) and fragment cached image ({remote_url}#options). Ofc, I can fix it just by adding extra check `r.Options.String() == "0x0", but I have some questions:

  1. why it works like that?
  2. is there any problem to disable caching for 0x0 version of image?
willnorris commented 4 years ago

interesting... I'm not sure why I've never paid attention to that before. You're definitely right that it's double caching the unmodified image, and we should fix that. I don't think it will be quite as simple as checking for "0x0", since depending on where you do that check, you miss out on things like checking for whether a 304 response should be returned.

I'll certainly leave this open to fix when I get a chance. Looking at the TransformingTransport also reveals some wasteful reading of the response when no transformation is going to take place, so some of this code may be do for a larger refactor.