sillygod / cdp-cache

a caddy 2 proxy cache plugin
MIT License
120 stars 18 forks source link

downloaded again after the service restarts #38

Open wusertu opened 3 years ago

wusertu commented 3 years ago

I have a problem with the same file being downloaded again after the service restarts

sillygod commented 3 years ago

@wusertu hi,

Well, I am sorry I don't understand what you mean. Could you please elaborate on it with an example? That will help me to understand what you've encountered.

love4taylor commented 3 years ago

@sillygod Like this, request the file once to get the cache, then restart the caddy service and request the file again, then the same file is downloaded repeatedly

love4taylor@EGOIST:/data/caddy/cache/pximg$ ll -h
total 2.7M
drwxr-xr-x 2 root root  32K Jul 19 23:28 ./
drwxr-xr-x 3 root root 4.0K Jul 19 13:37 ../
-rw------- 1 root root 1.3M Jul 19 23:28 caddy-cache-855862080
-rw------- 1 root root 1.3M Jul 19 23:28 caddy-cache-966089272
love4taylor@EGOIST:/data/caddy/cache/pximg$ sudo sha256sum caddy-cache-*
b76b8760c4db809ed87b647eead9c8ad58a4daebd0e1e14c00412f9730dae689  caddy-cache-855862080
b76b8760c4db809ed87b647eead9c8ad58a4daebd0e1e14c00412f9730dae689  caddy-cache-966089272
love4taylor@EGOIST:/data/caddy/cache/pximg$
sillygod commented 3 years ago

oh, ok. This situation will happen when the cache type is set to file. I will fix this in my spare time. If you hurry, you may try to use an in-memory cache instead. here is the example settings.

teodorescuserban commented 6 months ago

+1 to this issue.

The file system cache type is not managed after a caddy restart. The files remain on the filesystem, but are not taken into account by the cache - for example going to admin api curl -X GET localhost:2019/caches/ will return an empty response.

I see that the files themselves do not contain any information about the cache_key like nginx does.

I do commend you for:

I hope you do have a bit of time to fix this, it already looks really nice!