From d27f1c81df9906ff01f8f42d9649191d167f1a9a Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Wed, 12 Jul 2017 17:42:41 -0500 Subject: [PATCH] Boost: Add simple caching rules for woff font files to avoid loading OpenSans at each request --- .htaccess | 8 ++++++++ documentation/installation_guide.html | 10 ++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.htaccess b/.htaccess index ad2bcce53d..ec1b9be77e 100644 --- a/.htaccess +++ b/.htaccess @@ -61,3 +61,11 @@ RewriteRule ^([^/.]+)/?$ user.php?$1 [L] # Deny access RewriteRule ^(tests|.git) - [F,L,NC] + +# Add caching of woff font files to avoid loading 2*15KB each time with Chamilo +# default OpenSans font +AddType application/font-woff .woff .woff2 + + ExpiresActive On + ExpiresByType application/font-woff "access plus 1 month" + diff --git a/documentation/installation_guide.html b/documentation/installation_guide.html index ee044ff075..d92b8fe282 100755 --- a/documentation/installation_guide.html +++ b/documentation/installation_guide.html @@ -736,6 +736,12 @@ If you have issues with files taking a long time to download, make sure you reco RewriteRule ^([^/.]+)/?$ user.php?$1 [L] RewriteRule ^(tests|.git) - [F,L,NC] </Directory> + + AddType application/font-woff .woff .woff2 + <IfModule mod_expires.c> + ExpiresActive On + ExpiresByType application/font-woff "access plus 1 month" + </IfModule>

Nginx

Nginx doesn't support .htaccess rules, so you have no other option than to apply the following rules (note that your PHP backend configuration may vary). @@ -791,8 +797,8 @@ If you have issues with files taking a long time to download, make sure you reco } # Serve static files directly - location ~* \.(png|jpe?g|gif|ico|js|css|mp3|swf|flv|mp4|ogg)$ { - expires 1y; + location ~* \.(png|jpe?g|gif|ico|js|css|mp3|swf|flv|mp4|ogg|woff|woff2)$ { + expires 30d; access_log off; rewrite ^/courses/([^/]+)/course-pic85x85.png$ /app/courses/$1/course-pic85x85.png last; rewrite ^/courses/([^/]+)/course-pic.png$ /app/courses/$1/course-pic.png last;