I'd like to set up a cache server for downloaded files. One twist is that I want it to work with HTTPS (including redirects from HTTP to HTTPS). I understand the usual problems with this, but the difference for me is that this does not need to be a transparent proxy. For example:
# Usually you'd do something like this:
curl --proxy myserver:8080 https://example.com/file.tar.gz
# But it's fine for our scripts to call something like this instead:
curl myserver:8080 --data-raw https://example.com/file.tar.gz
Note that here the client is specifically directing its request at myserver, so it's not going to try and verify that the reponse comes from example.com
. (My server should though!)
The other twist is this will only be used for files that never change (the URLs include the version number) so the usual stuff about cache freshness doesn't apply. If the file (or redirect response) is cached then it should be returned without checking the internet at all. The cached copy should be deleted some fixed period after it is last requested, regardless of when first downloaded at our end.
Question: I had hoped to use an HTTP proxy like Squid but I can't see how to configure it to do anything like this. Alternatively, writing a bit of code is an option but I'd prefer to avoid that. What could I do to establish a cache like this?
Background: This is to be used mostly for third-party libraries we'll use in our source code, when building Docker images and when developers are building outside of containers. Sometimes we currently check in third-party code to our own repos but this isn't ideal. I'm sure we're not the only people facing this problem but I can't find a good solution on the web ... maybe I'm just missing the right search term.