Do not cache custom FAQ component

dipu2

26-08-2020

Dear All,

 

I have one page called sunita.html and some components are there like text , title etc with my custom component FAQ.

 

My requirement is that whenever end user will hit the page sunita.html then my custom component FAQ will not be cached. I have used sling dynamic include and done the below steps and still this is not working.

 

**********************Dispatcher.any*********************

/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"

/nocache {
/glob "*.nocache.html*"
/type "deny"
}
}
}

 

************** httpd.conf *********************

<VirtualHost *:80>
ServerAdmin admin@sunita.com
DocumentRoot "C:/Users/sunita_c/AEM-LOCAL-ENVIRONMENT/DISPATCHER/cache"
ServerName BGL124908.sunita.com
ServerAlias www.BGL124908.sunita.com
ErrorLog "logs/BGL124908.sunita.com-error.log"
CustomLog "logs/BGL124908.sunita.com-access.log" common

<Directory C:/Users/sunita_c/AEM-LOCAL-ENVIRONMENT/DISPATCHER/cache>
<IfModule disp_apache2.c>
SetHandler dispatcher-handler
</IfModule>
Options Indexes FollowSymLinks Includes
# To process .html files for server-side includes (SSI):
AddOutputFilter INCLUDES .shtml
AllowOverride None
</Directory>
</VirtualHost>

 

****************** Sling Dynamic Include **************************

 

dipu2_0-1598500902026.png

 

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

dipu2

02-09-2020

Dear All,

 

Now my issue is fixed and coming fine after adding below changes in my vhost conf file.

 

<Directory C:/Users/sunita_c/Sunita-Work/AEM-LOCAL-ENVIRONMENT/DISPATCHER/cache>

<IfModule disp_apache2.c>
SetHandler dispatcher-handler
ModMimeUsePathInfo On
</IfModule>

Options FollowSymLinks includes
AllowOverride None

AddOutputFilter INCLUDES .html

# Apache httpd 2.2
Order allow,deny
Allow from all
</Directory>

Answers (5)

Answers (5)

dipu2

31-08-2020

Hi Andrei and Jörg_Hoh,

 

Dear all, I tried all the steps , but still my FAQ component is not displaying and did below steps.

 

I am using Apache 2.2 and followed the below adobe help document and configured my dispatcher for SDI.

https://docs.adobe.com/content/help/en/experience-manager-learn/foundation/development/set-up-sling-...

 

I have changed my httpd.conf like below.


# ***********************************
# Adobe CQ5 Dispatcher Configuration
# ***********************************
# Dispatcher Configuration
LoadModule dispatcher_module modules/disp_apache2.2.dll

# Configuration for dispatcher module to be enabled with CQ5

<IfModule disp_apache2.c>
# location of the configuration file. eg: 'conf/dispatcher.any'
DispatcherConfig conf/dispatcher.any

# location of the dispatcher log file. eg: 'logs/dispatcher.log'
DispatcherLog logs/dispatcher.log

# log level for the dispatcher log # 0 Errors
# 1 Warnings
# 2 Infos
# 3 Debug
DispatcherLogLevel 3

# Defines the Server Header to be used:
# undefined or 0 - the HTTP server header contains the CQ version.
# if turned to 1, Apache server header is used
DispatcherNoServerHeader 0

# if turned to 1, request to / are not handled by the dispatcher
# use the mod_alias then for the correct mapping
DispatcherDeclineRoot 0
# Defines whether to use pre-processed URLs:
# 0 - use the original URL passed to the web server.
# 1 - the dispatcher uses the URL already processed by the handlers
# that precede the dispatcher
# (i.e. mod_rewrite) instead of the original URL passed to the server.
DispatcherUseProcessedURL 0
DispatcherPassError 0
</IfModule>

# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).

# First, we configure the "default" to be a very restrictive set of
# features.

<VirtualHost *:80>
ServerAdmin admin@sunitaint.com
DocumentRoot "C:/Users/sunita_c/Sunita-Work/AEM-LOCAL-ENVIRONMENT/DISPATCHER/cache"
ServerName BGL124908.sunitaint.com
ServerAlias www.BGL124908.sunitaint.com
ErrorLog "logs/BGL124908.sunitaint.com-error.log"
CustomLog "logs/BGL124908.sunitaint.com-access.log" common

<Directory C:/Users/sunita_c/Sunita-Work/AEM-LOCAL-ENVIRONMENT/DISPATCHER/cache>

<IfModule disp_apache2.c>
SetHandler dispatcher-handler
</IfModule>
Options Indexes FollowSymLinks Includes
# To process .html files for server-side includes (SSI):
AddOutputFilter INCLUDES .shtml
AllowOverride None
</Directory>
</VirtualHost>

 

And I have added below (in red text) in my dispatcher.any file.

 

# The rules section defines what responses should be cached based on
# the requested URL. Please note that only the following requests can
# lead to cacheable responses:
#
# - HTTP method is GET
# - URL has an extension
# - Request has no query string
# - Request has no "Authorization" header (unless allowAuthorized is 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"

/nocache {
/glob "*.nocache.html*"
/type "deny"
}
}

 

After changing  the configured extension to ".html" , I am getting below error.

 
 

SDSI-errpor.PNG

 

 

Can you please help me on this ?

 

Hi @dipu2,

As per your previous message, the resource on Publish is <!--#include virtual="/content/referencesite/us/en/faq/_jcr_content/root/container/container/faq_1189772069.nocache.html" --></div>, whereas on Dispatcher the path is /content/referencesite/us/en/faq/_jcr_content/root/container/container/faq.nocache.html.
The path to the included resource should be the same on both Publish and Dispatcher.

My guess is that Dispatcher has cached page html containing improper path (e.g. during intermediate configuration). Can you please try to clear Dispatcher cache for /content/referencesite/us/en/faq and re-check the page on Dispatcher? In addition, can you please ensure that the same path is contained in page html source on both Publish and Dispatcher in the following comment (placed right before your component):
<!-- SDI include (path: /content/referencesite/us/en/faq/_jcr_content/root/container/container/faq_1189772069.nocache.html, resourceType: sunita/components/faq/v1/faq) -->

Regards

Thanks Andrei,

I have deleted faq from my dispatcher cache and again requested.

 

In my publish instance I am seeing below.

 

publish-sdi.PNG

 

<div class="faq aem-GridColumn aem-GridColumn--default--12"><!-- SDI include (path: /content/referencesite/us/en/faq/_jcr_content/root/container/container/faq.nocache.html, resourceType: kf/components/faq/v1/faq) -->
<h1> FAQ Component </h1>

<div>sunita testing for dispatcher config</div></div>
<div class="image aem-GridColumn aem-GridColumn--default--12">
</div>

 

But in my dispatcher , I am seeing below.

 

Dispatcher-sdi.PNG

 

</div>
<div class="faq aem-GridColumn aem-GridColumn--default--12"><!-- SDI include (path: /content/referencesite/us/en/faq/_jcr_content/root/container/container/faq.nocache.html, resourceType: kf/components/faq/v1/faq) -->
<!--#include virtual="/content/referencesite/us/en/faq/_jcr_content/root/container/container/faq.nocache.html" --></div>
<div class="image aem-GridColumn aem-GridColumn--default--12">
</div>

 

But , I observed one thing that in my dispatcher.log file I am getting below error.

[C:\Users\sunita_c\Sunita-Work\AEM-LOCAL-ENVIRONMENT\DISPATCHER\cache\.stat] -> use cache

[C:\Users\sunita_c\Sunita-Work\AEM-LOCAL-ENVIRONMENT\DISPATCHER\cache\content\referencesite\us\en\faq.html]
[Tue Sep 01 20:12:23 2020] [D] [pid 22336 (tid 1196)] cache-action for [/content/referencesite/us/en/faq.html]: DELIVER
[Tue Sep 01 20:12:23 2020] [D] [pid 22336 (tid 1196)] request declined
[Tue Sep 01 20:12:23 2020] [I] [pid 22336 (tid 1196)] "GET /content/referencesite/us/en/faq.html" - - 0ms

Hi @Andrei_Dantsou, Now my issue is fixed and coming fine after adding below in my conf file.

 

<Directory C:/Users/sunita_c/Sunita-Work/AEM-LOCAL-ENVIRONMENT/DISPATCHER/cache>

<IfModule disp_apache2.c>
SetHandler dispatcher-handler
ModMimeUsePathInfo On
</IfModule>

Options FollowSymLinks includes
AllowOverride None

AddOutputFilter INCLUDES .html

# Apache httpd 2.2
Order allow,deny
Allow from all
</Directory>

Jörg_Hoh

Employee

27-08-2020

First of all, you configured SSI to be active only files with the extension ".shtml". You can either reconfigure AEM a bit to handle that extension as well, or you can just change the configured extension to ".html"; it will add a small overhead to each HTML request, but that's probably not a problem in the first place.

 

Then please describe, what you mean "it is still not working"? Is that FAQ component missing in the rendered HTML?

dipu2

27-08-2020

Thanks Andrei,

 

Previously , I did not install the bundle "Apache Sling Dynamic Include" in my publish instance (localhost:4503)...But Now I have installed and changed accordingly below.

 

dipu2_0-1598532858869.png

 

After Changed in the "dynamic include config" in publisher , I am able to see the comments in my html file like below.

 

<div class="faq aem-GridColumn aem-GridColumn--default--12"><!-- SDI include (path: /content/referencesite/us/en/faq/_jcr_content/root/container/container/faq_1189772069.nocache.html, resourceType: sunita/components/faq/v1/faq) -->
<!--#include virtual="/content/referencesite/us/en/faq/_jcr_content/root/container/container/faq_1189772069.nocache.html" --></div>

 

But , I am not able to see my FAQ value in the website , as shown below.

 

dipu2_1-1598534251974.png

 

But I am able to see the FAQ value in my publish instance , as shown below.

 

dipu2_2-1598534959003.png

 

Is there anything I am missing ?

 

 

Andrei_Dantsou

27-08-2020

Hello @dipu2 ,

First of all, could you please confirm that on your Publish instance the bundle "Apache Sling Dynamic Include" is installed, the corresponding configuration for "Apache Sling Dynamic Include - Configuration" is set, and you see the similar comment in source code of the page close to your component (due to the "Add comment" checkbox in the config):
<!-- SDI include (path: /content/we-retail/language-masters/en/user/mailbox/_jcr_content/root/responsivegrid/text.nocache.html, resourceType: weretail/components/content/text) -->

If the comment is missing, the configuration on Publish should be double-checked prior to digging into Dispatcher configs.

Regards

kautuk_sahni

Community Manager

27-08-2020

@Jörg_Hoh @kunal23 @Runal_Trivedi Can you please assist us with this question?