What cache settings to use for freebsd-update reverse proxy

I'm using the directions from https://wiki.freebsd.org/VladimirKrstulja/Guides/FreeBSDUpdateReverseProxy to setup a reverse proxy for freebsd-update but I was wondering what are the preferred cache settings. I need to upgrade 6 jails so this cache should save some download time.

I've added the following line

Code:
proxy_cache_path    /var/cache/nginx levels=1:2 keys_zone=freebsd_update:10m;

to the http section of nginx.conf. When monitoring the directory size I see it fluctuating between 10MB and 40MB while doing an upgrade to 11.1-RELEASE in one of my jails.

Also, should I use the same directory here as the document root (/var/cache/freebsd-update/) or is it better to use another directory as I've done.
 
Also, should I use the same directory here as the document root (/var/cache/freebsd-update/) or is it better to use another directory as I've done.

Note, even though it says so in the original article, this is a forward proxy, not a reverse proxy.

I'm using Apache for this:
Code:
<VirtualHost *:80>
        ServerAdmin info@example.com
        ServerName fbsd-update.example.com

        ProxyRequests Off
        ProxyPreserveHost Off

        <Proxy *>
                Order Deny,Allow
                Allow from All
        </Proxy>

        ProxyPass / http://update.freebsd.org/

        <Location />
                ProxyPassReverse /
                Order Allow,Deny
                Allow from All
        </Location>

        <IfModule cache_module>
                <IfModule disk_cache_module>
                        CacheEnable disk /
                        CacheRoot /var/cache/freebsd-update/
                </IfModule>
        </IfModule>

</VirtualHost>
And I have htcacheclean running to keep the cache clean:
Code:
htcacheclean_cache="/var/cache/freebsd-update/"
htcacheclean_enable="YES"
 
A late reaction but I managed to get things working by adjusting some of the defaults used:

Code:
proxy_cache_path    /var/cache/nginx levels=1:2 keys_zone=freebsd_update:10m max_size=500M inactive=24h;

This will allow for 10 million keys, maximum cache size of 500MB and keys are removed after 24 hours of inactivity. Especially that last parameter caused lots of trouble as the inactivity timeout is set to 10 minutes by default.
 
I'm using Apache for this:
Code:
        <IfModule cache_module>
                <IfModule disk_cache_module>
                        CacheEnable disk /
                        CacheRoot /var/cache/freebsd-update/
                </IfModule>
        </IfModule>
The proxy part of your config worked for me but the caching did not. One problem is that the disk cache module is called cache_disk_module. But even after I fixed that I the cache was still not working. I think the problem is that FreeBSD update servers do not return a Last-Modified header. The solution I found was to enable CacheIgnoreNoLastMod. Here's my apache cache config:
Code:
    <IfModule cache_module>
        <IfModule cache_disk_module>
            CacheEnable disk /
            CacheRoot /var/cache/freebsd-update
            CacheDirLevels 2
            CacheDirLength 1
            CacheIgnoreNoLastMod On
            CacheDetailHeader On
            CacheIgnoreHeaders Set-Cookie
        </IfModule>
    </IfModule>
 
Back
Top