Sitemap XML get Cache on Dispatcher Server | Community
Skip to main content
Level 2
May 28, 2021
Solved

Sitemap XML get Cache on Dispatcher Server

  • May 28, 2021
  • 4 replies
  • 4497 views

Hi Friends ,

  Whenever user Activate , Deactivate or Delete AEM Pages. Changes are not reflected on Sitemap XML. Is there any way to deal with this?

 

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 MarkusBullaAdobe

Hi @sanket_dange!

 

If this is a caching issue, it is probably related to the statfileslevel [1] in your dispatcher configuration. The dispatcher invalidates certain parts of the content tree in the cache based on this configuration. The general recommendation is to set the statfileslevel as high as possible but as low as necessary for your website. This may somehow be conflicting with the Sitemap XML as it is usually placed at the root of the website.

 

There are different ways to handle this, depending on the overall structure of your website:

  • Move the sitemap.xml to a higher level in the content hierarchy so that it lies within the invalidated area covered through the statfileslevel setting.
    You can manage the URL to the sitemap through rewrite rules on the dispatcher and still expose it externally on the root level.
  • User ACS AEM Commons Dispatcher Flush Rules [2] to define a mapping that invalidates the sitemap whenever a page of your website is invalidated.
  • Usually not the best solution: decrease the statfileslevel until it also invalidates your sitemap xml.

 

If this is not a caching issue it is hard to give advice without any knowledge about your implementation of the sitemap xml generation.

 

Hope that helps!

 

[1] https://experienceleague.adobe.com/docs/experience-manager-dispatcher/using/configuring/dispatcher-configuration.html?lang=en#invalidating-files-by-folder-level

[2] https://adobe-consulting-services.github.io/acs-aem-commons/features/dispatcher-flush-rules/index.html

4 replies

MarkusBullaAdobe
Adobe Employee
MarkusBullaAdobeAdobe EmployeeAccepted solution
Adobe Employee
May 28, 2021

Hi @sanket_dange!

 

If this is a caching issue, it is probably related to the statfileslevel [1] in your dispatcher configuration. The dispatcher invalidates certain parts of the content tree in the cache based on this configuration. The general recommendation is to set the statfileslevel as high as possible but as low as necessary for your website. This may somehow be conflicting with the Sitemap XML as it is usually placed at the root of the website.

 

There are different ways to handle this, depending on the overall structure of your website:

  • Move the sitemap.xml to a higher level in the content hierarchy so that it lies within the invalidated area covered through the statfileslevel setting.
    You can manage the URL to the sitemap through rewrite rules on the dispatcher and still expose it externally on the root level.
  • User ACS AEM Commons Dispatcher Flush Rules [2] to define a mapping that invalidates the sitemap whenever a page of your website is invalidated.
  • Usually not the best solution: decrease the statfileslevel until it also invalidates your sitemap xml.

 

If this is not a caching issue it is hard to give advice without any knowledge about your implementation of the sitemap xml generation.

 

Hope that helps!

 

[1] https://experienceleague.adobe.com/docs/experience-manager-dispatcher/using/configuring/dispatcher-configuration.html?lang=en#invalidating-files-by-folder-level

[2] https://adobe-consulting-services.github.io/acs-aem-commons/features/dispatcher-flush-rules/index.html

arunpatidar
Community Advisor
Community Advisor
May 28, 2021

If you are using ACS Common, you can delete sitemap.xml from the dispatcher cache as soon as you publish anything/page

Arun Patidar
June 2, 2021

in farm.any file
/0028 { /type "allow" /glob "* /homep.sitemap.xml*" }

 and

/cache
{
/invalidate
{
/0000 { /glob "* /homep.sitemap.xml*" /type "allow"}
}
}

when I have added /invalidate then homep.sitemap.xml file is deleted on dispatcher. I want to invalidate not to delete that file. file.

Level 2
September 24, 2021

Hi Sank,

 

Did you got solution for this?

July 18, 2024

 

To set up a cache for a sitemap XML on a dispatcher server (typically in an AEM environment), follow these steps:

  1. Ensure Dispatcher Caching is Enabled: Make sure your dispatcher is set up to cache content. This involves configuring the dispatcher.any file to allow caching for specific file types and paths.

  2. Modify Dispatcher Configuration:

    • Open your dispatcher.any file and locate the /rules section.
    • Add a rule to cache the sitemap XML. This typically looks like:
      bash
      Copy code
      /rules { /0000 { /glob "*" /type "allow" } /0001 { /glob "*.xml" /type "allow" } }
  3. Set up Cache Headers: Configure your web server (e.g., Apache, Nginx) to set appropriate cache headers for the sitemap.xml file. This ensures that the sitemap XML is cached for a reasonable period.

    • In Apache, you can set cache headers using the mod_expires module:
      graphql
      Copy code
      <Files "sitemap.xml"> ExpiresActive On ExpiresDefault "access plus 1 day" </Files>
  4. Flush Dispatcher Cache: After setting up caching, ensure to flush the dispatcher cache to apply changes. This can be done manually or by using an automated script.

  5. Testing: Verify that the sitemap XML is being cached correctly by checking the response headers and ensuring that the file is being served from the cache.

Example Configuration in Dispatcher.any

Here’s a simplified example of how your dispatcher.any file might look with caching for XML files enabled:

 

plaintext
Copy code
/cache { /docroot "/path/to/cache" /rules { /0000 { /glob "*" /type "allow" } /0001 { /glob "*.xml" /type "allow" } } /invalidate { /0000 { /glob "*.html" } /0001 { /glob "*.xml" } } }
 

Tips for Better Performance

  • Increase Cache Expiry: Set a reasonable expiry time for the sitemap XML to reduce frequent cache invalidation.
  • Use Dispatcher Flush Agent: Configure a dispatcher flush agent in AEM to automatically invalidate the cache when content changes.

Resources

  • Adobe Documentation: Refer to Adobe's official documentation on Configuring Dispatcher for more detailed instructions.
  • Web Server Configuration: Check your web server’s documentation for setting cache headers (e.g., Apache mod_expires, Nginx caching).

If you need more specific guidance or have a unique setup, feel free to provide more details.


https://www.ravi-gupta.com/