0

Somehow I can't get Apache's mod-cache to work as I want. I want it to cache a proxy call to my tomcat server which is a jsp file. The jsp file displays the current time so I can notice if I get a cached response or not.. This is my config:

        CacheQuickHandler off
        CacheLock on
        CacheLockPath /tmp/mod_cache-lock
        CacheLockMaxAge 5
        CacheIgnoreHeaders Set-Cookie

       <Location /Kanzan/>
          CacheEnable disk
          CacheHeader on
          CacheDefaultExpire 800
          CacheMaxExpire 64000
          CacheIgnoreNoLastMod On
          #ExpiresActive on
          #ExpiresDefault A60
       </Location>


       ProxyPreserveHost On
       ProxyPass /Kanzan/ http://127.0.0.1:8080/Kanzan/
       ProxyPassReverse /Kanzan/ http://127.0.0.1:8080/Kanzan/

All this is inside my virtual host. I do log this in 5 different files,

cached-requests.log
cache.log
invalidated-requests.log
revalidated-requests.log
uncached-requests.log

But only cache.log and the 2 last ones ever get content. In the last file I allways get

127.0.0.1 [21/sep/2018xxxxx +0200] "GET /Kanzan/testCache.jsp HTTP/1.1" 200 472

and in cache.log I repeatedly get

cache miss: attempting entity save

I get data saved to /var/cache/apache2/mod_cache_disk, but the the cache is never used as the time keeps updating on reload..

UPDATE:

Now I realize that the cache works... BUT ... it does not work the way I want it to. When I press refresh on my browser I want the cached value on the server to be returned if it hasn't expired.. instead, whenever I press refresh, the chache is updated! How do I make it work so that the cached value is not updating whenever a new user require this page??

  • What do the HTTP response headers coming from the tomcat server look like? – guzzijason Sep 22 '18 at 2:03
  • I get nothing in the head tag.. Only the <title> tag is there.. – user2908112 Sep 22 '18 at 8:31
  • Sorry, this is the headers I get from tomcat: Content-length: 259, Content-Type: text/html;charset=UTF-8, Date: ..... – user2908112 Sep 22 '18 at 11:28
0

Just add this

CacheIgnoreCacheControl on

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.