Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Caching in Publish instance

Avatar

Level 3

Hi,

I wanna cache publish requests and responses.

 

I did changes in dispatcher.any for publish instance.

After restarting the apache webserver for the first request am getting Geometrix welcome page but for the second request amgetting html page.

Ex:

<!DOCTYPE HTML> <html> <head> <meta charset="utf-8" /> <title>Geometrixx Outdoors</title> <link rel="canonical" href="http://192.168.5.109/content/geometrixx-outdoors/en.html"/> <link rel="shortcut icon" href="https://forums.adobe.com/etc/designs/geometrixx-outdoors/favicon.ico"/> <script> document.documentElement.className+=' js'; /*@cc_on(function(){var e=['abbr','article','aside','audio','canvas','details','figcaption','figure','footer','header','hgroup','mark','meter','nav','output','progress','section','summary','time','video'];for (var i = e.length; i-- > 0;) document.createElement(e[i]);})();@*/ </script> <script type="text/javascript" src="/etc/clientlibs/granite/jquery.js"></script> <script type="text/javascript" src="/etc/clientlibs/granite/utils.js"></script> <script type="text/javascript" src="/etc/clientlibs/granite/jquery/granite.js"></script> <script type="text/javascript" src="/etc/clientlibs/foundation/jquery.js"></script> <script type="text/javascript" src="/etc/clientlibs/foundation/shared.js"></script> <script type="text/javascript" src="/etc/designs/geometrixx-outdoors/clientlibs_desktop_v1.js"></script> <link rel="stylesheet" href="https://forums.adobe.com/etc/designs/geometrixx-outdoors/clientlibs_desktop_v1.css" type="text/css">

 

The dispatcher config file is..

# Each farm configures a set of load balanced renders (i.e. remote servers)
/farms
  {
  # First farm entry
  /publish 
    {  
    # Request headers that should be forwarded to the remote server.
    /clientheaders
      {
      # Forward all request headers that are end-to-end. If you want
      # to forward a specific set of headers, you'll have to list
      # them here.
      "*"
      }
      
    # Hostname globbing for farm selection (virtual domain addressing)
    /virtualhosts
      {
      # Entries will be compared against the "Host" request header
      # and an optional request URL prefix.
      #
      # Examples:
      #
      #   www.company.com
      #   intranet.*
      #   myhost:8888/mysite
      "*"
      }
      
    # The load will be balanced among these render instances
    /renders
      {
      /rend01
        {
        # Hostname or IP of the render
        /hostname "192.168.5.109"
        # Port of the render
        /port "4503"
        # Connect timeout in milliseconds, 0 to wait indefinitely
        # /timeout "0"
        }
      }
      
    # The filter section defines the requests that should be handled by the dispatcher.
    # The globs will be compared against the request line, e.g. "GET /index.html HTTP/1.1".
    /filter
      {
      /0000
        {
        /url "/*"
        /type "allow"
        }
      # Deny external access to system console
      /0001
        {
        /url "/system/*"
        /type "allow"
        }
      # Deny external access to CRX web application
      /0002
        {
        /url "/crx*"
        /type "allow"
        }
      # Deny external access to servlet engine console
      /0003
        {
        /url "/admin/*"
        /type "allow"
        }
      # allow  access to logout 
      /0004
        {
        /url "/system/sling/logout*"
        /type "allow"
        }
      }  
  
    # The cache section regulates what responses will be cached and where.
    /cache
      {
      # The docroot must be equal to the document root of the webserver. The
      # dispatcher will store files relative to this directory and subsequent
      # requests may be "declined" by the dispatcher, allowing the webserver
      # to deliver them just like static files.
      /docroot "/opt/cq/publish/crx-quickstart/dispatcher/cache"

      # Sets the level upto which files named ".stat" will be created in the 
      # document root of the webserver. When an activation request for some 
      # page is received, only files within the same subtree are affected 
      # by the invalidation.
      #/statfileslevel "0"
      
      # Flag indicating whether to cache responses to requests that contain
      # authorization information.
      # This needs to be set to "1" for an author instance, as all requests
      # to an author instance contain authorization information.
      # This means that the cache rules must never allow caching of content
      # that contains user specific information.
      /allowAuthorized "0"
      
      # Flag indicating whether the dispatcher should serve stale content if
      # no remote server is available.
      #/serveStaleOnError "0"
      
      # 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
          {
          # Disallow any caching by default and subsequently allow caching
          # for content that may be cached although requested with authorization
          # information present in the request
          /glob "*"
          /type "allow"
          }
        /0001
          {
          # Allow caching of requests to /libs
          /glob "/libs/*"
          /type "allow"
          }
        /0002
          {
          # This contains user information
          /glob "/libs/cq/security/userinfo.*"
          /type "deny"
          }
        /0003
          {
          # This page contains a "Welcome, User XXX" message
          /glob "/libs/cq/core/content/welcome.*"
          /type "allow"
          }
        # /0004
        # If your application is designed to allow caching of requests to /apps
        # enable this rule after careful validation that no user specific content
        # is cached.
        #   {
        #   /glob "/apps/*"
        #   /type "allow"
        #   }
        }
        
      # The invalidate section defines the pages that are "invalidated" after
      # any activation. Please note that the activated page itself and all 
      # related documents are flushed on an modification. For example: if the 
      # page /foo/bar is activated, all /foo/bar.* files are removed from the
      # cache.
      /invalidate
        {
        /0000
          {
          /glob "*"
          /type "deny"
          }
        /0001
          {
          # Consider all HTML files stale after an activation.
          /glob "*.html"
          /type "allow"
          }
        /0002
          {
          /glob "/etc/segmentation.segment.js"
          /type "allow"
          }
        /0003
          {
          /glob "*/analytics.sitecatalyst.js"
          /type "allow"
          }
        }

      # The allowedClients section restricts the client IP addresses that are
      # allowed to issue activation requests.
      /allowedClients
        {
        # Uncomment the following to restrict activation requests to originate
        # from "localhost" only.
        #
        #/0000
        #  {
        #  /glob "*"
        #  /type "deny"
        #  }
        #/0001
        #  {
        #  /glob "127.0.0.1"
        #  /type "allow"
        #  }
        }
        
      # The ignoreUrlParams section contains query string parameter names that
      # should be ignored when determining whether some request's output can be
      # cached or delivered from cache.
      #
      # In this example configuration, the "q" parameter will be ignored. 
      #/ignoreUrlParams
      #  {
      #  /0001 { /glob "*" /type "deny" }
      #  /0002 { /glob "q" /type "allow" }
      #  }
      
      }
      
    # The statistics sections dictates how the load should be balanced among the
    # renders according to the media-type. 
    /statistics
      {
      /categories
        {
        /html
          {
          /glob "*.html"
          }
        /others
          {
          /glob "*"
          }
        }
      }
    }
  }

 

Please let me know if i did any mistake.

 

Thanks in Advance,

Mahesh

1 Accepted Solution

Avatar

Correct answer by
Level 8

Some links:

ModMimeUsePathInfo: see the same-named section below http://dev.day.com/docs/en/cq/current/deploying/dispatcher/disp_install.html#Apache%20Web%20Server

DispatcherUseProcessedURL: For an example for use when apache rewrites the incoming url, see https://dev.day.com/docs/en/cq/current/deploying/dispatcher/disp_domains.html#The%20Web%20Server%20R...

 

scott

View solution in original post

10 Replies

Avatar

Level 7

Hi
In you httpd.conf -file, whats the status of your "DispatcherUseProcessedURL" ?
I had problems with that and it caused the same problem but fixed it by setting that parameter to 1, but it was on a separate dispatcher server..

/Johan
 

Avatar

Level 8

Why have you commented out the statfileslevel property? Is the .stat file still being created in the cache?

#/statfileslevel "0"

 

scott

Avatar

Level 10

The ModMimeUsePathInfo parameter should be set On for all Apache configurations

Avatar

Level 3

Hi Johan,

I didnt find the DispatcherUseProcessedURL in the Apache conf file.

 

Let me know where i can modify.

Thanks 

Mahesh

Avatar

Level 3

Hi Sham,

 

Where i can set on for ModMimeUsePathInfo?

 

Thanks

Mahesh

Avatar

Level 7

Hi, you can set both the DispatcherUseProcessedURL 1 and the ModMimeUsePathInfo in the  "httpd.conf" file. Here is some sample config info from the dev.day.com information pages..
 

<IfModule disp_apache2.c> //..more configs DispatcherUseProcessedURL 1 //.....more configs </IfModule> //... <VirtualHost *:80> ServerName branda.com DocumentRoot /usr/lib/apache/httpd-2.4.3/htdocs/content/sitea <Directory /usr/lib/apache/httpd-2.4.3/htdocs/content/sitea> <IfModule disp_apache2.c> SetHandler dispatcher-handler ModMimeUsePathInfo On </IfModule> Options FollowSymLinks AllowOverride None </Directory> </VirtualHost>

Avatar

Correct answer by
Level 8

Some links:

ModMimeUsePathInfo: see the same-named section below http://dev.day.com/docs/en/cq/current/deploying/dispatcher/disp_install.html#Apache%20Web%20Server

DispatcherUseProcessedURL: For an example for use when apache rewrites the incoming url, see https://dev.day.com/docs/en/cq/current/deploying/dispatcher/disp_domains.html#The%20Web%20Server%20R...

 

scott

Avatar

Level 3

I have implemented everything what you said but am getting same i.e., 

First Request getting --> Geometrix page

Second Request(Means refreshing the page) --> Getting html page with text.

Am getting this only if the param set to allow in rules section

 /rules
      {
        /0000
        {
          # Disallow any caching by default and subsequently allow caching
          # for content that may be cached although requested with authorization
          # information present in the request
          /glob "*"
          /type "allow"
          }

Then only it will caches and getting the above two steps.

If i set that deny then it caches nothing but for any numbers of request to a publish i get the page.

Please point me in right direction to cache the publish instance request and response.

Thanks

Mahesh

Avatar

Level 3

Thanks Scott.

Now am able to cache the requests and responses for both the instances.

Thanks 

Mahesh

Avatar

Level 7

Sounds more like that the dispatcher don't get enough information about what it sends back from the cache.
For example if you want to deliver something from the cache you need to make sure that you have included the right info in the page regarding content type so that the cache know how to deliver it.

  • Have you set "DefaultType text/plain" in the httpd.conf ?
  • Also in your page, have you set e.g. <!DOCTYPE html> and <%@page contentType="text/html; charset=utf-8" %> ?

For special types like .myspecialtype you might also need to add that information to the httpd.conf like "AddType application/xml myspecialtype"
Good luck
/Johan