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 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<i>api or via the web. (/x/ and /y/), oh and I added the nodeinfo</i>2 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 actaully 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 old disk cache. (under debian see /etc/default/apache-htcacheclean or else the relevant systemd service or whatever)<br>Then add to the snac 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 /s/, /x/ and /y/ Path, as well as for /$username/nodeinfo<i>2</i>0, utilizing the mod_expires 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 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 defaults to set <code>no-cache</code> on that location and the mod<i>expires will honor that if we don't override it. I set it to the same Cache-Control value as mod</i>expores woud. (mod_expires 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><br>