OceanBrowser with disk cache

From GHER

Jump to: navigation, search

Without cache enabled in Apache:

$ wget -S -O out  'http://localhost/web-vis-test/Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0'
--2015-06-23 22:22:15--  http://localhost/web-vis-test/Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 200 OK
  Date: Tue, 23 Jun 2015 20:22:15 GMT
  Server: Apache/2.4.7 (Ubuntu)
  Vary: Accept-Encoding
  Cache-Control: must-revalidate, max-age=5
  Last-Modified: Tue, 23 Jun 2015 20:08:03 GMT
  Keep-Alive: timeout=5, max=100
  Connection: Keep-Alive
  Transfer-Encoding: chunked
  Content-Type: text/xml

Enable caching

sudo a2enmod cache_disk
Considering dependency cache for cache_disk:
Enabling module cache.
Enabling module cache_disk.
To activate the new configuration, you need to run:
  service apache2 restart

Configuration

The file /etc/apache2/sites-enabled/000-default.conf:

<VirtualHost *:80>
       ServerAdmin webmaster@localhost
       [...]
       <IfModule mod_cache.c>
         CacheEnable disk /web-vis-test
       </IfModule>
       [...]
       CustomLog ${APACHE_LOG_DIR}/access.log combined
       CustomLog ${APACHE_LOG_DIR}/cache-access.log common
       CustomLog ${APACHE_LOG_DIR}/cache-cached-requests.log common env=cache-hit
       CustomLog ${APACHE_LOG_DIR}/cache-uncached-requests.log common env=cache-miss
       CustomLog ${APACHE_LOG_DIR}/cache-revalidated-requests.log common env=cache-revalidate
       CustomLog ${APACHE_LOG_DIR}/cache-invalidated-requests.log common env=cache-invalidate
</VirtualHost>


The file /etc/apache2/mods-enabled/cache_disk.conf

<IfModule mod_cache_disk.c>
   # This path must be the same as the one in /etc/default/apache2
   CacheRoot /var/cache/apache2/mod_cache_disk

   # Enable the X-Cache header
   CacheHeader on

   # Enable the X-Cache-Detail header
   CacheDetailHeader on

   # The result of CacheDirLevels * CacheDirLength must not be higher than
   # 20. Moreover, pay attention on file system limits. Some file systems
   # do not support more than a certain number of inodes and
   # subdirectories (e.g. 32000 for ext3)
   CacheDirLevels 2
   CacheDirLength 1

</IfModule>



With cache enabled

$ wget -S -O out  'http://localhost/web-vis-test/Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0'
--2015-06-23 22:18:05--  http://localhost/web-vis-test/Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 
 HTTP/1.1 200 OK
 Date: Tue, 23 Jun 2015 20:18:05 GMT
 Server: Apache/2.4.7 (Ubuntu)
 Last-Modified: Tue, 23 Jun 2015 20:08:03 GMT
 Vary: Accept-Encoding
 Cache-Control: must-revalidate, max-age=5
 X-Cache: REVALIDATE from 127.0.1.1
 X-Cache-Detail: "conditional cache hit: entity refreshed" from 127.0.1.1
 Content-Length: 314565
 Keep-Alive: timeout=5, max=100
 Connection: Keep-Alive
 Content-Type: text/xml

See also log files for cache.

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

References

http://serverfault.com/questions/448281/setting-up-apache-as-a-forward-proxy-with-caching

Personal tools