caching images is not happening in AEM

Refresh

March 2019

Views

972 time

1

I have the below configuration file for caching in dispatcher. I am able to cache js,css but not JPEG/PNG's. Kindly suggest me if i am going wrong somewhere? I need to cache images as well

ExpiresActive On
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
ExpiresDefault "access plus 2 days"

This is the dispatcher.any file configuration

# Hello Publish Farm
/publishfarm_hello
{
# client headers which should be passed through to the render instances
# (feature supported since dispatcher build 2.6.3.5222)
/clientheaders
  {
  "referer"
  "user-agent"
  "authorization"
  "from"
  "content-type"
  "content-length"
  "accept-charset"
  "accept-encoding"
  "accept-language"
  "accept"
  "host"
  "if-match"
  "if-none-match"
  "if-range"
  "if-unmodified-since"
  "max-forwards"
  "proxy-authorization"
  "proxy-connection"
  "range"
  "cookie"
  "cq-action"
  "cq-handle"
  "handle"
  "action"
  "cqstats"
  "depth"
  "translate"
  "expires"
  "date"
  "dav"
  "ms-author-via"
  "if"
  "lock-token"
  "x-expected-entity-length"
  "destination"
  }
# hostname globbing for farm selection (virtual domain addressing)
/virtualhosts
  {
  $include "publish-vhosts-hello.any"
  }
# the load will be balanced among these render instances
/renders
  {
  $include "publish-renders-hello.any"
  }
# only handle the requests in the following acl. default is 'none'
# the glob pattern is matched against the first request line
/filter
  {
  $include "publish-filter-hello.any"
  }

# allow propagation of replication posts (should seldomly be used)
/propagateSyndPost "0"

# the cache is used to store requests from the renders for faster delivery
# for a second time.
/cache
  {
  # the cacheroot must be equal to the document root of the webserver
  /docroot "/mnt/var/www/html/content/hello"

  # sets the level upto which files named ".stat" will be created in the
  # document root of the webserver. when an activation request for some
  # handle is received, only files within the same subtree are affected
  # by the invalidation.
  /statfileslevel "0"

  # caches also authorized data
  /allowAuthorized "0"

  # the rules define, which pages should be cached. please note that
  # - only GET requests are cached
  # - only requests with an extension are cached
  # - only requests without query parameters ( ? ) are cached
  # - only unauthorized pages are cached unless allowUnauthorized is set to 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"
      }
/0003 
  {
      #added for Hello Online Forms
  /glob "/content/hello-online-forms[./]*" /type "deny"
  }
  }
  # the invalidate section defines those pages which 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
      {
      /glob "*.html"
      /type "allow"
      }
    /0002
      {
      /glob "*.css"
      /type "allow"
      }
    }
  /allowedClients
    {
    /0000
      {
      /glob "*.*.*.*"
      /type "deny"
      }
    $include "publish-invalidate-allowed.any"
    }
  }
# the statistics define, how the load should be balanced among the renders
# according to the media-type.
/statistics
  {
  /categories
    {
    /html
      {
      /glob "*.html"
      }
    /others
      {
      /glob "*"
      }
    }
  }

2 answers

2

As per AEM documentation, you can control which documents are cached based appropriate document path using the "/rules" property. Please check if you have configuration similar to below under the /rules property

/rules
    {
    # initial blanket deny
    /0000
      {
      /glob "*"
      /type "deny"
      }
    # low-change static assets
    /0001
      {
      /glob "*.png"
      /type "allow"
      }
    /0002
      {
      /glob "*.gif"
      /type "allow"
      }
    /0003
      {
      /glob "*.jpg"
      /type "allow"
      }
    /0004
      {
      /glob "*.jpeg"
      /type "allow"
      }

If its there as per the adobe link, there are certain circumstances given under which the dispatcher never caches a document. Please see if your case matches any of those circumstances

0

Do you see the images in the dispatcher cache? Basically the configuration you have shared is for mod_expire and has nothing to do with dispatcher. As far as i remember mod_expire won't apply the header unless the resource is served from apache (not steamed from AEM).