Quantcast
Channel: linuxadmin: Expanding Linux SysAdmin knowledge
Viewing all articles
Browse latest Browse all 17790

A couple questions regarding basic Squid cache usage

$
0
0

I work with a lot of virtual machines (Vagrant / VirtualBox). Throughout that process, I find myself repeatedly fetching a lot of the same resources (apt-get ..., docker pull ..., etc...). As a result, I thought I might save myself a lot of time by caching those requests through Squid. To get started, I've installed a simple Squid server called SquidMan (my host is OS X).

I now have an Ubuntu VM in front of me, to which I've added the following to its /etc/environment file:

http_proxy=http://10.0.50.1:8080 https_proxy=http://10.0.50.1:8080 HTTP_PROXY=http://10.0.50.1:8080 HTTPS_PROXY=http://10.0.50.1:8080 

10.0.50.1 is the IP address of my OS X host. I am able to make a direct connection to squid from the VM with the following command:

$ nc -v 10.0.50.1 8080 

Now consider the following two examples by which I'm trying to verify that caching is working:

Caching over HTTP - Works

First, I'll download a hi-res photo over http:

$ wget http://images.unsplash.com/photo-1466046690866-98181611563d 

The first request takes several seconds, as expected. Subsequent attempts to download the same image are near instantaneous, and I see entries show up in Squid's log file. Great.

Caching over HTTPS - Does Not Work

Now, when I try to download the same image over HTTPS, caching has no effect:

$ wget https://images.unsplash.com/photo-1466046690866-98181611563d 

Any ideas as to what I'm doing wrong? You should be able to cache https requests such as this via Squid, right? Don't all / most downloads via apt, etc... occur over HTTPS?


Update - Squid Logs

Here are a few relevant entries from Squid's logs. The first entry shows a successful request for a previously-cache image. The second two lines relate to requests for the same image over HTTPS - the result was not cached.

1468935825.889 297 ::1 TCP_REFRESH_UNMODIFIED/200 16901940 GET http://images.unsplash.com/photo-1466046690866-98181611563d - HIER_DIRECT/151.101.32.188 image/jpeg 1468935851.412 10200 ::1 TCP_TUNNEL/200 16935910 CONNECT images.unsplash.com:443 - HIER_DIRECT/151.101.32.188 - 1468935878.414 9763 ::1 TCP_TUNNEL/200 16935910 CONNECT images.unsplash.com:443 - HIER_DIRECT/151.101.32.188 - 
submitted by /u/sotimting
[link] [comments]

Viewing all articles
Browse latest Browse all 17790

Trending Articles