Hi ,
I am looking to set Cache-Control no-cache header for below URL.
Using sling dynamic include for dynamic content and need to make sure component html responds with specific headers to have dispatcher, CDN not to cache.
I have already set up osgi config for sling dynamic include , set component ttl to 0.
I am thinking following would be fine.
<IF "%{REQUEST_URI} =~ '/content/.*\.nocache.html.*'">
Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
Header set Pragma "no-cache"
Header set Age 0
</IF>
http://localhost.company.com:8080/content/invest/en/simple-web/sreeni-test/test-loginaware/_jcr_content/root/container/experiencefragment_l.nocache.html/simple-web/components/content/experiencefragment-login-aware/v1/experiencefragment-login-aware
Please let me know.
I am facing an issue where mainpage.html talking to dispatcher if page loaded with browser refresh.
But, If I copy paste the mainpage.html url directly onto new tab, request not even hitting dispatcher and seems request served either from browser cache or CDN.
more details on the issue:
Unless I provide a query parameter , request never went to dispatcher.
And always returning page from "Disk Cache" which I believe browser cache.
It would be helpful, if anyone could share how can we avoid "Disk Cache" and have the request go to CDN at the least ( I am assuming CDN in turn request dynamic component from dispatcher , publisher)
Views
Replies
Total Likes
Hi @sreenu539 ,
As rule written is for specific component(SDI enabled component ) not for the page so it will get cached as page is not having nocache selector.
Only that component will be loaded dynamically not the whole page.
Also, the If
directive is available in Apache 2.4 and later versions only you may use location match directive
<LocationMatch "/content/.*\.nocache.html.*">
Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
Header set Pragma "no-cache"
Header set Age 0
</LocationMatch>
To deny caching for sdi enabled component below rules should be added in cache section of dispacther
/0110 {
/glob "*.nocache.html"
/type "deny"
}
If requirement is not to cache whole mainpage.html at CDN then below rules can be written
<LocationMatch "^/content/.*mainpage\.html$">
Header set Cache-Control "public, max-age=86400, must-revalidate"
Header set Expires "Wed, 21 Oct 2024 07:28:00 GMT"
Header set Age 86400
</LocationMatch>
Rule to deny cache at dispatcher level as well, rule can be added to filter section
/0113 {
/glob "/content/.*mainpage\.html.*"
/type "deny"
}
Thanks
Views
Replies
Total Likes
If you’re using a CDN, review its cache configuration to ensure that mainpage.html is bypassed or set to respect origin headers. CDNs sometimes cache based on the URL structure unless explicitly instructed otherwise, which can lead to cached responses even with Cache-Control headers
Views
Replies
Total Likes
Thanks for your reply @Sh1ju
Unless I provide a query parameter , request never went to dispatcher.
And always returning page from "Disk Cache" which I believe browser cache.
It would be helpful, if you could share how can we avoid this and have the request go to CDN at the least ( I am assuming CDN , in turn request dynamic component from dispatcher , publisher)
Thanks!
Views
Replies
Total Likes
Hi @sreenu539
If you're using a CDN, then Server-Side Includes (SSI) or Server-Side Dynamic Include (SDI) won't be effective for caching purposes. This is because the dispatcher prepares the complete page response and delivers it to the CDN, which then caches everything, as does the browser if cache-control headers are present. The only advantage SDI provides in this setup would be at the dispatcher level, and it wouldn’t extend to the CDN or browser cache.
Views
Likes
Replies
Views
Likes
Replies