Skip to content
This repository has been archived by the owner on Oct 18, 2020. It is now read-only.

cache-control / max-age on images #315

Open
torch2424 opened this issue Jul 12, 2017 · 6 comments
Open

cache-control / max-age on images #315

torch2424 opened this issue Jul 12, 2017 · 6 comments

Comments

@torch2424
Copy link

Hello!

I am a huge fan of droppy, and I use it on almost all of my servers (raspberry pis and droplets). I have a few personal hobby websites that I embed images from directly from my droppy (using the sharing link), and noticed that the requests are not being cached.

screen shot 2017-07-12 at 1 44 57 am

I was wondering if there was something I could set in the config, or the client, to get image or certain file types to have certain headers (for a longer cache).

Let me know if you would like to have this implemented in the project, or if you think it would be a good idea. I could work on a PR for it if maintainers are working on other things.

Thanks!

@silverwind
Copy link
Owner

I opted to not set any cache headers because the content can potentially be quite dynamic, but I could add an option where you specify a cache duration on sharelinks, in seconds. Which value would you set?

Oh, and by the way: From your screenshot, I see that your links are created as downloads. For embedding images in websites, it'd probably be better to uncheck the download option.

@torch2424
Copy link
Author

Hello!

Nice to hear back, that was super fast! Thanks dude!

That would be super cool, If you would like I can open a PR for it, doesn't sound too bad. I just usually open issues to discuss ideas on peoples projects before trying to throw something in it haha!

For static assests I'm using on my blog and Github repos, they haven't changed in months, and when they do, usually it's a new link, so I'd probably set it for the max, or something reasonably long.

And I'll try unchecking download, thanks!

Also, after doing a bit more research, do you think I could set the headers/caching in nginx? Was looking at my nginx config, and noticed that may be an option.

Thanks again for the quick response!

@silverwind
Copy link
Owner

do you think I could set the headers/caching in nginx?

Yes, I think something like this might work (setting cache duration to 1 month on all sharelinks):

location /$/ {
  add_header "Cache-Control" "public, max-age=2678400";
}

As for a PR, I think I'll decline that one unless you're a expert on browser caching 😉 . It's not that trivial of a change because one has to consider dev mode where I do not like to have any sort of caching and then there's also the ETag caching mechanism (only used for static resources right now). I think I'll investigate applying ETag caching to all resources as it's a mechanism that can work without me having to add another option.

@torch2424
Copy link
Author

Oh nice, I'll try that out tonight! Thanks!

And I am no means an expert on browser caching haha! And that does sound nice. Yeah development would be a pain if there was any type of caching enabled. Thanks again for the consideration!

@silverwind
Copy link
Owner

Okay, I've added a weak ETag-based cache to all file downloads. It's based on file path and last modification date, which should be sufficient for our use. I'll release v6.6.10 with it in a few minutes.

@torch2424
Copy link
Author

torch2424 commented Jul 18, 2017

Oh nice! Thanks for that! Also, the little nginx snippet you passed me works well! I actually recently just converted to Caddy Since it's so much easier to set-up/maintin. But either way, I got it working from there.

Though, I am quite excited to experiment with the Etag as well, I try this out when it's not 2AM where I am haha! So maybe tommorow night?

Thanks again!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants