Browser Caching ETAG etc

23 views
Skip to first unread message

Christoph Damm

unread,
Jun 25, 2024, 8:41:03 AM6/25/24
to Magnolia User Mailing List
Hello,
I wanted to ask if someone has experience / a go to way to modify the browsercaching headers sent by Magnolia. I did some parts there already but have another use case now.
Generally we do send a long max-age (a year) via the browser cache policies ( https://docs.magnolia-cms.com/product-docs/6.3/modules/list-of-modules/cache-modules/cache-core/#_cache_strategies) since all our file names either have a fingerprint from magnolia or from ourselves.
However, now I have the case where I cannot (well i don't want to) change the filename after a deployment. These are files (1 js and 1 css) consumed by external partners.
So, ideally I would want to send something like "no-cache" and an ETAG, hence it can be cached but has to be validated. The header part is not the big problem, I already implemented an extension class of SetExpirationHeaders class to add the immutable parameter to the cache-control header, if needed.
So with this I could set the headers I want (maybe by also creating an own voting result).

But, long story short: Is there anything built in that would handle the read of the "if-none-match" request header (which will contain my etag from first response) when the file is requested an return a non modified response or do i have to create an own filter or something similiar for that?
Or is this something that you handle normally on a webserver in front of magnolia?
We have that as well, but somehow I would not like it if caching strategies are spread over too many systems.

Cheers

Christoph

Roman Kovařík

unread,
Jun 25, 2024, 9:19:52 AM6/25/24
to Magnolia User Mailing List, [email protected]
Hi Christoph,

If you want to handle this in Magnolia, I'd probably look into customising UseCache.java and overriding ifModifiedSince. As you can see, the if-none-match case is not handled. You can then set your custom class here.

Hope that helps
Roman
Reply all
Reply to author
Forward
0 new messages