In my project, I am working on caching control for downloadable assets in AEM. I have written a cache rule to handle assets with URLs following these patterns:
Example URL for myprojectdownload assets:
Example URL for coredownload assets:
To ensure these assets are cached correctly, I have added the following LocationMatch rule in the Apache configuration:
<LocationMatch "^/content/dam/.*\.(coredownload|myprojectdownload)\.(?i:pdf).*">
Header set Cache-Control "max-age=95400, stale-while-revalidate=1800, stale-if-error=43200, public, immutable" "expr=%{REQUEST_STATUS} < 400"
Header set Age 0
</LocationMatch>
Despite implementing the above cache rule, the cache control headers are missing from the response. Below is the current response header
accept-ranges: bytes
age: 0
content-disposition: attachment; filename="112 .pdf"
content-encoding: gzip
content-type: application/pdf
permissions-policy: private-state-token-redemption=()
permissions-policy: private-state-token-issuance=()
permissions-policy: run-ad-auction=()
permissions-policy: join-ad-interest-group=()
vary: Accept-Encoding
x-cache: MISS
x-content-type-options: nosniff
x-frame-options: ORIGIN
x-served-by: cache-BOM
I expect the response to include the Cache-Control header with the specified directives so that these assets can be cached properly by browsers and CDNs.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @RahulSi13 ,
Below are the answers to your queries.
1. Why is the Cache-Control header missing, despite being explicitly set in the configuration?
<LocationMatch "^/content/dam/.*\.(coredownload|myprojectdownload)\.pdf$">
// check if it is enabled
apachectl -M | grep headers
//If not enabled, Activate it
a2enmod headers
systemctl restart apache2
grep -Ri "Header unset Cache-Control" /etc/apache2/
/clientheaders
{
"Cache-Control"
}
2. How can I ensure that cache control settings are correctly applied to these assets?
// Curl Command
curl -I https://dev-publish.myproject.com/content/dam/myproject/path/subsi/public/en/downloadsmajor-resolutions-of-board-meetings/112.pdf.coredownload.pdf
//Expected Output
Cache-Control: max-age=95400, stale-while-revalidate=1800, stale-if-error=43200, public, immutable
curl -I -H "Pragma: no-cache" https://your-server-ip/content/dam/...
Regards,
URL are :
dev-publish.myproject.com/content/dam/myproject/path/subsi/public/en/downloadsmajor-resolutions-of-board-meetings/112%A0%85.pdf.coredownload.pdf/%85_112%E5%B9%B4
dev1-publish.myproject.com/content/dam/myproject/path/subsi/public/en/downloadsmajor-resolutions-of-board-meetings/112%A0%85.pdf.myprojectdownload.pdf/%85_112%E5%B9%B4
Views
Replies
Total Likes
Hi @RahulSi13 ,
Below are the answers to your queries.
1. Why is the Cache-Control header missing, despite being explicitly set in the configuration?
<LocationMatch "^/content/dam/.*\.(coredownload|myprojectdownload)\.pdf$">
// check if it is enabled
apachectl -M | grep headers
//If not enabled, Activate it
a2enmod headers
systemctl restart apache2
grep -Ri "Header unset Cache-Control" /etc/apache2/
/clientheaders
{
"Cache-Control"
}
2. How can I ensure that cache control settings are correctly applied to these assets?
// Curl Command
curl -I https://dev-publish.myproject.com/content/dam/myproject/path/subsi/public/en/downloadsmajor-resolutions-of-board-meetings/112.pdf.coredownload.pdf
//Expected Output
Cache-Control: max-age=95400, stale-while-revalidate=1800, stale-if-error=43200, public, immutable
curl -I -H "Pragma: no-cache" https://your-server-ip/content/dam/...
Regards,
Views
Likes
Replies