Do not cache custom FAQ component | Community
Skip to main content
Level 3
August 27, 2020
Solved

Do not cache custom FAQ component

  • August 27, 2020
  • 6 replies
  • 5077 views

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 **************************

 

 

Thanks in advance.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by dipu2

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>

6 replies

kautuk_sahni
Community Manager
Community Manager
August 27, 2020

@joerghoh @kunal_gaba_ @runal_trivedi Can you please assist us with this question?

Kautuk Sahni
dipu2Author
Level 3
September 1, 2020
Hi , My issue is still there..Can you please mark this again an question "or" can I create a new thread ?
Andrei_Dantsou
Level 3
August 27, 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

dipu2Author
Level 3
August 27, 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.

 

 

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.

 

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

 

 

Is there anything I am missing ?

 

 

dipu2Author
Level 3
August 27, 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.

 

 

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.

 

 

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

 

 

Is there anything I am missing ?

 

 

Andrei_Dantsou
Level 3
August 27, 2020

@dipu2,

As far as I can see on the screenshots, the page on Dispatcher was cached previously ("faq" page title is present on Dispatcher, and it's missing on Publish).
Could you please try to clean the Dispatcher cache for this page and re-check?

joerghoh
Adobe Employee
Adobe Employee
August 27, 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?

dipu2Author
Level 3
August 31, 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-dynamic-include.html

 

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.

 
 

 

 

Can you please help me on this ?

 

Andrei_Dantsou
Level 3
September 1, 2020

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

dipu2AuthorAccepted solution
Level 3
September 2, 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>