Caching pages with suffix paths on AEM Dispatcher
Adobe AEM's dispatcher module has a significant weakness when it comes to caching pages with a suffix path: always either the page itself or the suffix page path are not cached.
Background
Let's assume we have a page /content/hitthecode/blog.html that can get rendered without suffix or with suffix:
/content/hitthecode/blog.html/suffix.html .
In the dispatcher cache file system, the "regular" page is stored in a file
/dispatcher/cache/content/hitthecode/blog.html
while the page with suffix would be
/dispatcher/cache/content/hitthecode/blog.html/suffix.html
The Issue
While /dispatcher/cache/content/hitthecode/blog.html is a file in the first scenario, it is a folder in the case of caching the page with suffix.
However, in a unix filesystem, the same path cannot be used for both a file and a suffix.
The Ugly Part
Once the directory /dispatcher/cache/content/hitthecode/blog.html/ has been created, any result to the page /dispatcher/cache/content/hitthecode/blog.html will result in an HTTP 301 response to /dispatcher/cache/content/hitthecode/blog.html/
If you have multiple dispatcher instances, this usually happens only on a subset of the instances, resulting an an unpredictable and confusion behavior.
The Complex Solution
I wrote about this issue almost 10 years ago, the blog article is still live on my previous employer's website:
https://one-inside.com/caching-pages-with-suffix-paths-in-aem-cq-dispatcher/
The Simple Solution
Try to avoid serving a resource both with and without suffix path.
Sounds simple?
For most use-cases you do control this and you can find a good way to solve it..
However, AEM DAM inherently does use suffix paths for serving renditions of images.
This is an example you will find in the we-retail sample:
/content/dam/we-retail/en/activities/hiking-camping/trekker-khumbu-valley.jpg/jcr:content/renditions/cq5dam.web.1280.1280.jpeg
(if you want to be picky: it's not actually a suffix path because "trekker-khumbu-valley.jpg" is the name of the resource rather than a resource with an extension, but the result is the same).
If your application includes images both with as a rendition and in the "original" version, you are affected by this issue.
/content/dam/we-retail/en/activities/hiking-camping/trekker-khumbu-valley.jpg