2016-01-26 54 views
1

我有下面的配置文件用於在調度程序中進行緩存。我能夠緩存js,css而不是JPEG/PNG。請告訴我,如果我在某個地方出錯了?我需要緩存圖像以及在AEM中沒有緩存圖像

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" 

這是dispatcher.any文件中的配置

# 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

按照AEM documentation,您可以控制哪些文件會被緩存使用「/法規爲基礎的適當的文件路徑「財產。 請檢查您是否有類似的配置,以低於下/規則屬性

/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" 
     } 

如果它的存在,因爲按照adobe link,也有給予一定的情況下,該調度員從不緩存文件。請參閱您的案例是否符合上述任何一種情況

+0

謝謝。我會查的。什麼是CSS,HTML和字體的規則,是這樣嗎? –

+0

這將是相同的'/ 0005 {glob。* .css「 /type」deny「 }'我在這裏否認集合,因爲有時候如果你有很高的更改資產,你可能想拒絕緩存。與JS(.js)和HTML(.html)相同 – snaem

+0

如果我們允許js,css文件。我們可以去調度員的緩存文件夾來查看這些嗎?我可以看到html的,json和圖片,但不是js或css。 –

0

您是否在調度程序緩存中看到圖像?基本上你共享的配置是用於mod_expire,並且與調度器無關。據我記得,mod_expire不會應用頭,除非資源從apache提供(不從AEM蒸發)。