Menel<b>Updated Version of the apache http caching setup for snac, including proxy media</b><br><br>I already wrote about caching <a href="https://snikket.de/social/menel/p/1738788742.236526" rel="nofollow noopener noreferrer" target="_blank">here</a>.<br>Now I extended what I cache a bit.<br>This was because after enabling the option to <a href="https://comam.es/snac-doc/snac.8.html#proxy_media" rel="nofollow noopener noreferrer" target="_blank">proxy media</a>, I've seen access to the file paths /x/ and /y/ in addition to the path were snac stores the media that I include in my own posts ( /s/ ).<br>There are two locations to proxy media, depending if you requests the media via the mastodon api or via the web. (/x/ and /y/), oh and I added the nodeinfo2.0 path too, because I've noticed it was queried all the time by a lot of instances and it gives me pleasure to see something cached handed out in the access logs. 🙂 (I guess it is actually irrelevant for the system resources)<br>This is the updated setup:<br>Enable the relevant modules:<br><br><code>a2enmod expires cache cache_disk</code><br><br>Be sure "htcacheclean" is running to clean up the old disk cache. (under debian see /etc/default/apache-htcacheclean or else the relevant systemd service or whatever)<br>Then add this to the httpd Virtualhost config:<br><br><pre><LocationMatch "^/social/[^/]+/[xys]/|^/social/nodeinfo_2_0"><br>CacheEnable disk<br>Header set Cache-Control "max-age=86400, public" "expr=%{REQUEST_STATUS} == 200"<br>ExpiresActive On<br>ExpiresDefault "access plus 86400 seconds"<br></LocationMatch><br></pre>This will use the disk cache to cache everything under the $username/s/, /x/ and /y/ paths, as well as for the <code>/nodeinfo_2_0</code> path, utilizing <code>mod_expires</code> to generate the appropriate cache headers (for lazy ones like me). In this case caching it for 1 day.<br>Further reading and all options are explained under <a href="https://httpd.apache.org/docs/2.4/caching.html" rel="nofollow noopener noreferrer" target="_blank">https://httpd.apache.org/docs/2.4/caching.html</a> (and ff)<br><br>The Header that I set here, on the condition of Status code 200, is needed for the path /y/, because snac set <code>no-cache</code> on that location and <code>mod_expires</code> will honor that if we don't override it. I set it to the same Cache-Control value as <code>mod_expires</code> would. (I use <code>mod_expires</code> because it will additionally calculate the date and put that in the <code>expires</code> header. (hence the name I guess 😀 )<br><br><a href="https://snikket.de/social?t=fediverse" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#Fediverse</a> <a href="https://snikket.de/social?t=hosting" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#Hosting</a> <a href="https://snikket.de/social?t=itnotes" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#ITNotes</a> <a href="https://snikket.de/social?t=apache2" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#apache2</a> <a href="https://snikket.de/social?t=httpd" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#httpd</a> <a href="https://snikket.de/social?t=ownyourdata" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#Ownyourdata</a> <a href="https://snikket.de/social?t=server" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#Server</a> <a href="https://snikket.de/social?t=snac" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#Snac</a> <a href="https://snikket.de/social?t=snac2" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#Snac2</a> <a href="https://snikket.de/social?t=tipsandtricks" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#Tipsandtricks</a> <a href="https://snikket.de/social?t=tutorial" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#Tutorial</a> <a href="https://snikket.de/social?t=debian" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#Debian</a> <a href="https://snikket.de/social?t=caching" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#caching</a><br>:xmpp:<br>