Nuria has uploaded a new change for review.
https://gerrit.wikimedia.org/r/158819
Change subject: [WIP] Adding caching headers for wikimetrics public directory
......................................................................
[WIP] Adding caching headers for wikimetrics public directory
Need to test ETAGs
Change-Id: Ie18def0d3c1469a3bb29c83bb0d2dec13d89a781
---
M manifests/web/apache.pp
M templates/wikimetrics.vhost.erb
2 files changed, 33 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet/wikimetrics
refs/changes/19/158819/1
diff --git a/manifests/web/apache.pp b/manifests/web/apache.pp
index 3e7c15f..331935c 100644
--- a/manifests/web/apache.pp
+++ b/manifests/web/apache.pp
@@ -19,6 +19,7 @@
include ::apache::mod::wsgi
include ::apache::mod::rewrite
include ::apache::mod::headers
+ include ::apache::mod::expires
file { "/etc/apache2/sites-available/${site}":
diff --git a/templates/wikimetrics.vhost.erb b/templates/wikimetrics.vhost.erb
index 660fdfa..772721d 100644
--- a/templates/wikimetrics.vhost.erb
+++ b/templates/wikimetrics.vhost.erb
@@ -32,6 +32,38 @@
# enable CORS requests
Header set Access-Control-Allow-Origin "*"
</Directory>
+
+ # Cache everything for up to a week
+ # HTML is retrieved every time
+ # Cache js/css for 1 week
+ # Cache json files 1 day
+ <Directory <%= @public_directory %>>
+ <IfModule mod_headers.c>
+ <FilesMatch "\.(eot|ttf|woff|png|gif)$">
+ Header set Cache-control "max-age=2592000,public"
+ </FilesMatch>
+ <FilesMatch ".(js|css)$">
+ Header set Cache-Control "max-age=640800, public, must-revalidate"
+ </FilesMatch>
+ <FilesMatch ".(json)$">
+ Header set Cache-Control "max-age=86400, public, must-revalidate"
+ </FilesMatch>
+ </IfModule>
+ </Directory>
+
+ <Directory <%= @public_directory %>>
+ # M86400 -> issue conditional request 1 day after modification
+ <IfModule mod_expires.c>
+ ExpiresActive On
+ ExpiresDefault M604800
+ ExpiresByType image/png "modification plus 1 month"
+ ExpiresByType image/gif "modification plus 1 month"
+ ExpiresByType application/x-font-ttf "access plus 1 month"
+ ExpiresByType application/x-font-opentype "access plus 1 month"
+ ExpiresByType application/x-font-woff "access plus 1 month"
+ </IfModule>
+ </Directory>
+
WSGIDaemonProcess api user=www-data group=www-data threads=10
python-path=<%= @docroot %>
WSGIScriptAlias / <%= @docroot %>/api.wsgi
--
To view, visit https://gerrit.wikimedia.org/r/158819
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie18def0d3c1469a3bb29c83bb0d2dec13d89a781
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet/wikimetrics
Gerrit-Branch: master
Gerrit-Owner: Nuria <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits