imagor icon indicating copy to clipboard operation
imagor copied to clipboard

Disable default caching

Open WatchDogsDev opened this issue 2 years ago • 2 comments

Hi, I tried using this as a docker image but it has problem with caching.

I don't want the cache header because of CDN caching, but I could not disable it.

I'm using docker-compose with these variables but still getting cache header with default values Cache-Control: public, s-maxage=86400, max-age=86400, no-transform

IMAGOR_CACHE_HEADER_NO_CACHE: 1
IMAGOR_CACHE_HEADER_TTL: 0h0m0s
IMAGOR_CACHE_HEADER_TTL: 0h0m0s

Please disable the cache for default.

WatchDogsDev avatar Jun 30 '22 13:06 WatchDogsDev

HI, IMAGOR_CACHE_HEADER_NO_CACHE=1 should do the job. A quick one to test it out:

docker run -p 8000:8000 shumc/imagor:0.9.7 -imagor-unsafe -imagor-cache-header-no-cache

Curl with response header only:

curl -sSL -D - 'http://localhost:8000/unsafe/200x200/smart/filters:fill(white):format(jpeg):quality(80)/https://raw.githubusercontent.com/cshum/imagor/master/testdata/gopher.png' -o /dev/null
HTTP/1.1 200 OK
Cache-Control: private, no-cache, no-store, must-revalidate
Content-Length: 7353
Content-Type: image/jpeg
Expires: Fri, 01 Jul 2022 08:55:47 GMT
Date: Fri, 01 Jul 2022 08:55:47 GMT

You may bee seeing the cached header because the result is cached. Please test under Chrome Incognito mode, or purging the CDN cache if you are serving Imagor behind a CDN or Cloudflare.

cshum avatar Jul 01 '22 09:07 cshum

HI, IMAGOR_CACHE_HEADER_NO_CACHE=1 should do the job. A quick one to test it out:

docker run -p 8000:8000 shumc/imagor:0.9.7 -imagor-unsafe -imagor-cache-header-no-cache

Curl with response header only:

curl -sSL -D - 'http://localhost:8000/unsafe/200x200/smart/filters:fill(white):format(jpeg):quality(80)/https://raw.githubusercontent.com/cshum/imagor/master/testdata/gopher.png' -o /dev/null
HTTP/1.1 200 OK
Cache-Control: private, no-cache, no-store, must-revalidate
Content-Length: 7353
Content-Type: image/jpeg
Expires: Fri, 01 Jul 2022 08:55:47 GMT
Date: Fri, 01 Jul 2022 08:55:47 GMT

You may bee seeing the cached header because the result is cached. Please test under Chrome Incognito mode, or purging the CDN cache if you are serving Imagor behind a CDN or Cloudflare.

Thanks for your answer.

I found that the problem was using old version of imagor (v0.8.8)

Upgrading to v0.9.7 solved the problem.

But isn't it better to disable caching by default and let anyone wants it enable it ?

WatchDogsDev avatar Jul 02 '22 05:07 WatchDogsDev