## empty cache
# htcacheclean -p /var/cache/apache2/mod_cache_disk -r -l 1
## verify that cache is empty
# htcacheclean -p /var/cache/apache2/mod_cache_disk -A
## make first request
# curl --verbose '
http://localhost/Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0' > out
* Connected to localhost (::1) port 80 (#0)
> GET /Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0 HTTP/1.1
> User-Agent: curl/7.38.0
> Host: localhost
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Tue, 14 Jul 2015 06:34:42 GMT
* Server Apache/2.4.10 (Ubuntu) is not blacklisted
< Server: Apache/2.4.10 (Ubuntu)
< Last-Modified: Mon, 13 Jul 2015 07:33:49 GMT
< Vary: Accept-Encoding
< X-Cache: MISS from 172.17.1.37
< X-Cache-Detail: "cache miss: attempting entity save" from 172.17.1.37
< Transfer-Encoding: chunked
< Content-Type: text/xml
<
## verify that first request is cached
# htcacheclean -p /var/cache/apache2/mod_cache_disk -A
http://localhost:80/Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0 422 3697448 200 0 1436855683140502 1436855688140502 1436855682866721 1436855683140502 1 0
## make second request (after 5 seconds)
# curl --verbose '
http://localhost/Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0' > out
* Hostname was NOT found in DNS cache
* Connected to localhost (::1) port 80 (#0)
> GET /Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0 HTTP/1.1
> User-Agent: curl/7.38.0
> Host: localhost
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Tue, 14 Jul 2015 06:34:59 GMT
* Server Apache/2.4.10 (Ubuntu) is not blacklisted
< Server: Apache/2.4.10 (Ubuntu)
< Last-Modified: Mon, 13 Jul 2015 07:33:49 GMT
< Vary: Accept-Encoding
< Cache-Control: must-revalidate, max-age=5
< X-Cache: REVALIDATE from 172.17.1.37
< X-Cache-Detail: "conditional cache hit: entity refreshed" from 172.17.1.37
< Content-Length: 3697448
< Content-Type: text/xml
<
## Yah! Cache is revalitated
# htcacheclean -p /var/cache/apache2/mod_cache_disk -A
http://localhost:80/Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0 472 3697448 200 0 1436855699443390 1436855704443390 1436855699441708 1436855699443390 1 0
## Make request when the users sends a "If-Modified-Since" header. Client (curl) has a stale copy, but the more recient version of the mod_cache can be revalidated.
# curl --verbose '
http://localhost/Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0' -H 'If-Modified-Since: Thu, 09 Jul 2015 20:26:45 GMT' > out
* Connected to localhost (::1) port 80 (#0)
> GET /Python/web/wms?request=GetCapabilities&service=WMS&version=1.3.0 HTTP/1.1
> User-Agent: curl/7.38.0
> Host: localhost
> Accept: */*
> If-Modified-Since: Thu, 09 Jul 2015 20:26:45 GMT
>
< HTTP/1.1 200 OK
< Date: Tue, 14 Jul 2015 06:35:32 GMT
* Server Apache/2.4.10 (Ubuntu) is not blacklisted
< Server: Apache/2.4.10 (Ubuntu)
< Last-Modified: Mon, 13 Jul 2015 07:33:49 GMT
< Vary: Accept-Encoding
< X-Cache: MISS from 172.17.1.37
< X-Cache-Detail: "cache miss: attempting entity save" from 172.17.1.37
< Transfer-Encoding: chunked
< Content-Type: text/xml
## Unfortunatetly, a cache miss.
root@1ce49e006c40:/var/oceanbrowser# cat /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 maximum size (in bytes) of a document to be placed in the cache
# GetCapabilities can be quite large, maximum here is 10 MB
CacheMaxFileSize 10000000
# 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>root@1ce49e006c40:/var/oceanbrowser# cat /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName
www.example.com ServerAdmin webmaster@localhost
DocumentRoot /var/www
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
# For debugging
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# Enable cache
<IfModule mod_cache.c>
CacheEnable disk /
</IfModule>
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
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<Directory /var/oceanbrowser/apache>
Require all granted
</Directory>
WSGIDaemonProcess
gher-diva.phys.ulg.ac.be processes=8 threads=15
WSGIProcessGroup
gher-diva.phys.ulg.ac.be WSGIScriptAlias / /var/oceanbrowser/apache/divaonweb.wsgi
WSGIApplicationGroup %{GLOBAL}
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet