Expand my Community achievements bar.

SOLVED

Sending Request to Dispatcher not Publish

Avatar

Level 4

Dear All,

I have an below requirement.

When I will request one page for example (http://localhost/content/we-retail/us/en/women.html) then the request will go to dispatcher cache not to Publish and

It request will display the page from Dispatcher cache not from publish.

Can anybody put some lights how can I achieve this.

I am using AEM 6.4

Thanks in advance.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Use case #1 is not an issue as you mentioned because it picks up the cached content from dispatcher, however, the hostname and port# in dispatcher.any file should be of the "publish server" that is supposed to serve the content to dispatcher and not apache server's.

You have configured 'statfileslevel' to 5 which I assume is intentional based on your app architecture/design.

When I will change my page in author http://localhost/content/trainingproject/en.html and activate the page then the updated page will store in the dispatcher cache (the /docroot). But in my case it is not storing in dispatcher cache.

I assume that you understand how dispatcher connects to the publish server, pulls the content from publish server because it is a reverse proxy and caches it as and when required. Check "How Dispatcher returns Documents"  @ Overview  in case you need more details.

When you activate the modified page, it would reside in the publish server but not in the dispatcher cache until the dispatcher requests for that updated page from publish server. This means it needs to know the publish server's IP/hostname and port to connect and pull the latest content. Render section (/rend01) of dispatcher.any serves this purpose to enable the communication between dispatcher and publish server. 

In your case #2, it is not storing updated content in dispatcher because the connection between dispatcher & publish server is broken. Yes, you're correct.

By default, the very first request would go to publish server and all subsequent requests for same content should be served from dispatcher cache in an ideal scenario.

View solution in original post

6 Replies

Avatar

Employee

Hello,

I would suggest you go through below link to understand how dispatcher performs the caching.

https://docs.adobe.com/content/help/en/experience-manager-dispatcher/using/dispatcher.html#how-dispa...

You would need to implement the /cache in the dispatcher.any file:

/cache

  {

  /docroot "/opt/dispatcher/cache"

  /statfile  "/tmp/dispatcher-website.stat"         

  /allowAuthorized "0"

  /rules

    {

    # List of files that are cached

    }

/invalidate

    {

    # List of files that are auto-invalidated

    }

  }

Check details from here : https://docs.adobe.com/content/help/en/experience-manager-dispatcher/using/configuring/dispatcher-co...

Avatar

Level 4

Thanks Vish.

I have updated my cache in dispatcher.any file like below and cache is working fine.

/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/communique/dispatcher/cache"

  /docroot "C:/Users/sunchoudhury/AEM-6.4/dispatcher/cache"

  /allowAuthorized "0"

Let me clear my requirement.

If the author will not do any changes in the page then the requested page will come from dispatcher cache only NOT FROM PUBLISH and if the author will do the changes in page and activate the content then the dispatcher cache will be updated with the updated page and the requested page will display the updated content from Dispatcher Cache.

For example

http://localhost:80/content/trainingproject/fr.html  ----> if page is updated in author , then updated page will be updated in cache and will come from cache.

http://localhost:80/content/trainingproject/fr.html  ----> if page will not be updated in author , then the last updated page will come from cache.

Thanks in advance

Avatar

Level 4

Dear All,

Anybody can put some lights in above.

Also can we do the render in dispatcher.any file in the below order.

First it will check in author  like below.

Then It will check in publish like below.

# The load will be balanced among these render instances

    /renders

      {

/rend01

        {     

        /hostname "localhost"

        # Port of the render

        /port "4502"

        # Connect timeout in milliseconds, 0 to wait indefinitely

        # /timeout "0"

        }

/rend02

        #{

          /hostname "localhost"

        # Port of the render

        /port "4503"

        # Connect timeout in milliseconds, 0 to wait indefinitely

        # /timeout "0"

        #}

      }

Can we render first /rend01 and then /rend02????????/

Can anybody please help me on this.

Thanks in advance.

Avatar

Level 10

Could you please explain your use case in detail?

Why would you connect both author and publish in same dispatcher.any file?

Avatar

Level 4

Hi Gaurav,

Thanks for replying. Below are my use cases. .

Use Case-1

For example I have a page in author (http://localhost:4502/content/trainingproject/en.html) .Now I did not change anything in this page and this page is static.

Now I am requesting this page from my dispatcher like below

http://localhost/content/trainingproject/en.html

My main requirement come here. When I request http://localhost/content/trainingproject/en.html then en.html page should come from dispatcher cache , not from publish.

When I request any page which is not changed then it will come from dispatcher cache. It is working fine. No issues here. But the issue comes in second use-case

To fulfill this I changed in my dispatcher.any file like below (in bold) and it is working fine.

# The load will be balanced among these render instances
    /renders
      {
/rend01
        {
        # Hostname or IP of the render
        /hostname "localhost"
        # Port of the render
        /port "80"
        # Connect timeout in milliseconds, 0 to wait indefinitely
        # /timeout "0"
        }
  
      }
     
  
    /filter
      {
      # Deny everything first and then allow specific entries
      /0001 { /type "deny" /glob "*" }
     
      # Open consoles
#     /0011 { /type "allow" /url "/admin/*"  }  # allow servlet engine admin
#     /0012 { /type "allow" /url "/crx/*"    }  # allow content repository
#     /0013 { /type "allow" /url "/system/*" }  # allow OSGi console
       
      # Allow non-public content directories
#     /0021 { /type "allow" /url "/apps/*"   }  # allow apps access
#     /0022 { /type "allow" /url "/bin/*"    }
      /0023 { /type "allow" /url "/content*" }  # disable this rule to allow mapped content only
     
#     /0024 { /type "allow" /url "/libs/*"   }
#     /0025 { /type "deny"  /url "/libs/shindig/proxy*" } # if you enable /libs close access to proxy

#     /0026 { /type "allow" /url "/home/*"   }
#     /0027 { /type "allow" /url "/tmp/*"    }
#     /0028 { /type "allow" /url "/var/*"    }

      # Enable extensions in non-public content directories, using a regular expression
      /0041
        {
        /type "allow"
        /extension '(clientlibs|css|gif|ico|js|png|swf|jpe?g|woff2?)'
        }

      # Enable features
      /0062 { /type "allow" /url "/libs/cq/personalization/*"  }  # enable personalization

      # Deny content grabbing, on all accessible pages, using regular expressions
      /0081
        {
        /type "deny"
        /selectors '((sys|doc)view|query|[0-9-]+)'
        /extension '(json|xml)'
        }
      # Deny content grabbing for /content
      /0082
        {
        /type "deny"
        /path "/content"
        /selectors '(feed|rss|pages|languages|blueprint|infinity|tidy)'
        /extension '(json|xml|html)'
        }

      # Uncomment the following to allow one-level json requests
#     /0087 { /type "allow" /method "GET" /extension "json" /selectors "1" }

      }

    # The cache section regulates what responses will be cached and where.
    /cache
      {
    
      # ###/docroot "/opt/communique/dispatcher/cache"
   /docroot "C:/Users/sunchoudhury/SUNITA-Work/AEM-6.3/dispatcher/cache"
   /allowAuthorized "0"    
      /statfileslevel "5"
     
    
      # - 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"
          }
        }
       
      # 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 "allow"
          }
        /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
        {
       
        }       
    

      }
     
    # The statistics sections dictates how the load should be balanced among the
    # renders according to the media-type.

Use Case-2

When I will change my page in author http://localhost/content/trainingproject/en.html and activate the page then the updated page will store in the dispatcher cache (the /docroot "C:/Users/sunchoudhury/SUNITA-Work/AEM-6.3/dispatcher/cache"). But in my case it is not storing in dispatcher cache. Can you please let me know how can I achieve this.

According to my knowledge it is not possible because when you will activate page and change the /port of rend01 to 4503 , then it will work.

/rend01

        {

        # Hostname or IP of the render

        /hostname "localhost"

        # Port of the render

        /port "80"

        # Connect timeout in milliseconds, 0 to wait indefinitely

        # /timeout "0"

        }

Please suggest.

Avatar

Correct answer by
Level 10

Use case #1 is not an issue as you mentioned because it picks up the cached content from dispatcher, however, the hostname and port# in dispatcher.any file should be of the "publish server" that is supposed to serve the content to dispatcher and not apache server's.

You have configured 'statfileslevel' to 5 which I assume is intentional based on your app architecture/design.

When I will change my page in author http://localhost/content/trainingproject/en.html and activate the page then the updated page will store in the dispatcher cache (the /docroot). But in my case it is not storing in dispatcher cache.

I assume that you understand how dispatcher connects to the publish server, pulls the content from publish server because it is a reverse proxy and caches it as and when required. Check "How Dispatcher returns Documents"  @ Overview  in case you need more details.

When you activate the modified page, it would reside in the publish server but not in the dispatcher cache until the dispatcher requests for that updated page from publish server. This means it needs to know the publish server's IP/hostname and port to connect and pull the latest content. Render section (/rend01) of dispatcher.any serves this purpose to enable the communication between dispatcher and publish server. 

In your case #2, it is not storing updated content in dispatcher because the connection between dispatcher & publish server is broken. Yes, you're correct.

By default, the very first request would go to publish server and all subsequent requests for same content should be served from dispatcher cache in an ideal scenario.