Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Cache action for root in Dispatcher - request without extension [/]

Avatar

Level 2

I am trying to work on a multidomain website and have used sling based mapping to map the domain to a landing page within AEM.

For eg. www.mobile.example.com --> is mapped to /content/example/mobile/home.html

So when user hits www.mobile.example.com, there is an internal redirection to /content/example/mobile/home.html and the same page is shown without the extension or content path.

So far so good. The only caveat to this is now this is root page for the dispatcher and it is not able to cache it and is saying: 

[Wed Nov 25 20:43:58 2015] [D] [6292(140029921134656)] checking [/] [Wed Nov 25 20:43:58 2015] [D] [6292(140029921134656)] request URL has no extension: / [Wed Nov 25 20:43:58 2015] [D] [6292(140029921134656)] cache-action for [/]: NONE

Is there a way to cache the root? I may sound a bit silly here but I want to avoid Apache URL rewrites (project limitation) 

My dispatcher cache settings are: 

# the cache is used to store requests from the renders for faster delivery # for a second time. /cache { # the cacheroot must be equal to the document root of the webserver /docroot "/var/www/html" # sets the level upto which files named ".stat" will be created in the # document root of the webserver. when an activation request for some # handle is received, only files within the same subtree are affected # by the invalidation. /statfileslevel "2" # caches also authorized data # allow httpd auth /allowAuthorized "0" # the rules define, which pages should be cached. please note that # - only GET requests are cached # - only requests with an extension are cached # - only requests without query parameters ( ? ) are cached # - only unauthorized pages are cached unless allowUnauthorized is set to 1 /rules { /0000 { # the globbing pattern to be compared against the url # example: *             -> everything #        : /foo/bar.*    -> only the /foo/bar documents #        : /foo/bar/*    -> all pages below /foo/bar #        : /foo/bar[./]* -> all pages below and /foo/bar itself #        : *.html        -> all .html files /glob "*" /type "allow" } }

 

Please let me know if anyone has an insight on this. 

 

1 Accepted Solution

Avatar

Correct answer by
Employee

@Lokesh, the link still uses a rewrite rule.

Hi Sharad,

I haven't come across this requirement before, I would reconsider your/your clients approach to not using rewrite rules. IMHO, you are limiting yourself by not using a very important aspect of the Apache Web Server. Ultimately, you should use the right tool for the job, a web server is created to do these kinds of tasks. If you go down this root, you will end up doing a workaround which even if possible won't be as simple or efficient as a rewrite rule.

Regards,

Opkar

View solution in original post

4 Replies

Avatar

Correct answer by
Employee

@Lokesh, the link still uses a rewrite rule.

Hi Sharad,

I haven't come across this requirement before, I would reconsider your/your clients approach to not using rewrite rules. IMHO, you are limiting yourself by not using a very important aspect of the Apache Web Server. Ultimately, you should use the right tool for the job, a web server is created to do these kinds of tasks. If you go down this root, you will end up doing a workaround which even if possible won't be as simple or efficient as a rewrite rule.

Regards,

Opkar

Avatar

Level 2

bsloki wrote...

see if [1] helps

[1] http://aemtreasury.com/2015/04/21/how-to-make-dispatcher-cache-vanity-url-which-without-extension/

 

Thanks Lokesh, but I was looking for something different. This still talks about Apache rewrite rules and I think I have to go down that road and use Apache for all redirections and rewrites as oppose to sling mapping. 

Avatar

Level 2

Opkar Gill wrote...

@Lokesh, the link still uses a rewrite rule.

Hi Sharad,

I haven't come across this requirement before, I would reconsider your/your clients approach to not using rewrite rules. IMHO, you are limiting yourself by not using a very important aspect of the Apache Web Server. Ultimately, you should use the right tool for the job, a web server is created to do these kinds of tasks. If you go down this root, you will end up doing a workaround which even if possible won't be as simple or efficient as a rewrite rule.

Regards,

Opkar

 

I think I have to check with the client as see what they have to say about this. It simply comes down to less maintenance at Apache layer and more at AEM I reckon. I would still try to convince them that it is always best to use rewrites in Apache. Thanks anyway for your help.