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

Clientside caching of clientlibs and images

Avatar

Level 1

Hello,

I'm working at a CQ5 application with activated Apache dispatcher module.
Clientlibs (CSS, Javascript) and images are getting cached by the dispatcher, but the browser every time receives a response code 200 instead of 304 for using the cached files on client side.
When I look at the response header I don't receive any ETag information. Could this be the fault?

 

Example response of clientlibs.js:

HTTP/1.1 200 OK Date: Thu, 25 Sep 2014 09:25:05 GMT Server: Apache/2.4.6 (Ubuntu) X-Frame-Options: SAMEORIGIN Accept-Ranges: bytes Vary: Accept-Encoding Content-Encoding: gzip Cache-Control: max-age=604800, public Expires: Thu, 02 Oct 2014 09:25:05 GMT Keep-Alive: timeout=5, max=85 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: application/javascript

The response header of CSS files and other images look analogous.
I want the browser to use the already loaded and cached files.

The current setting is:

<FilesMatch "\.(css|js|gif|jpe?g|png|ico)$"> FileETag MTime Size <IfModule mod_expires.c> ExpiresActive On ExpiresDefault "access plus 1 week" </IfModule> <IfModule mod_headers.c> Header append Cache-Control "public" </IfModule> </FilesMatch>

I also tried the newest version (4.1.8) of the dispatcher plugin (currently used 4.1.5), but no success.

Another user had a kind of similar question one year ago.

Do you have any suggestions? ETag should be enabled by default at Apache.

 

Kind regards,

Matthias

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hope you are aware of adv/disadvantage of adding etag.

It should work & also dispatcher does not have any role here & is apache mis configuration casing it.   Just for a debug can you add [1] in virtual host directive & let me know how it goes.

[1]  FileETag MTime Size

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

Hope you are aware of adv/disadvantage of adding etag.

It should work & also dispatcher does not have any role here & is apache mis configuration casing it.   Just for a debug can you add [1] in virtual host directive & let me know how it goes.

[1]  FileETag MTime Size

Avatar

Level 2

How was this marked as a correct answer, when the problem raised is not solved.

Avatar

Level 1

Hello Sham,

Thanks for your reply.

I already tried just with active dispatcher and the above stated config (deleted all the rewrite rules etc) and it didn't work.

Even if I just activate and configure the dispatcher module and do nothing else, no ETag will be served.

DocumentRoot "/dispatcher-cache" <Directory "/dispatcher-cache"> <IfModule disp_apache2.c> SetHandler dispatcher-handler ModMimeUsePathInfo On </IfModule> SetOutputFilter INCLUDES Options FollowSymLinks Includes AllowOverride None Require all granted </Directory> LoadModule dispatcher_module /mod_dispatcher.so <IfModule disp_apache2.c> # location of the configuration file. eg: 'conf/dispatcher.any' DispatcherConfig /dispatcher.any # location of the dispatcher log file. eg: 'logs/dispatcher.log' DispatcherLog    /var/log/apache2/dispatcher.log # log level for the dispatcher log # 0 Errors # 1 Warnings # 2 Infos # 3 Debug DispatcherLogLevel 3 DispatcherNoServerHeader 1 DispatcherDeclineRoot 0 DispatcherPassError 0 DispatcherUseProcessedURL 1 </IfModule>

 

The basic Apache configuration has not been changed at all.