Issue with Cache Control for Download Assets in AEM
Background
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:
Implemented Cache Rule
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>
Issue Encountered
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
Expected Behavior
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.
Questions
- Why is the Cache-Control header missing, despite being explicitly set in the configuration?
- How can I ensure that cache control settings are correctly applied to these assets?
Any insights or recommendations would be greatly appreciated!