CaramelFur / Picsur

An easy to use, selfhostable image sharing service like Imgur with built in converting
https://picsur.org/
GNU Affero General Public License v3.0
774 stars 41 forks source link

[Feature request] Send Cache-Control header so that images are loaded from the server only the first time #53

Closed crosa7 closed 8 months ago

crosa7 commented 1 year ago

First, thanks a lot for this awesome project, was looking for something like this for a while!

I just setup picsur and I noticed that when I request the image from my website, the image is always loaded from the server instead of only the first time and then the next calls will load them from memory-cache.

I searched a bit and I believe it is due to the missing Cache-Control header on the response (I don't have much knowledge on this). Would it be possible to implement this? It would make loading images in a website much more performant, and also avoid calls to the server all the time. Thanks a lot!

CaramelFur commented 1 year ago

Not sure why this was closed, but it seems like something worth looking into, thanks.

crosa7 commented 1 year ago

I had closed this as this could be achieved in another way and I wasn't sure if it was something you would like to have as a responsibility of picsur itself. Thanks for re-opening

chennin commented 11 months ago

Relatedly, an "ETag" header https://en.wikipedia.org/wiki/HTTP_ETag would be useful so clients can ask if the image was modified, and Picsur can send a 304 Not Modified back (or not).

CaramelFur commented 8 months ago

Since the url to an image will always be the same image, there doesn't need to be any check to see if the data has changed. The next release will now by default cache images for a month.