#7629 src.fp.o and pagure.io: cache headers for /static/vendor/emojione/emojione.sprites.png
Closed: Fixed 6 months ago by kevin. Opened 6 months ago by jlanda.

  • Describe what you need us to do:

Would be possible to add some caching policies to allow public caching of this file for a while? It's a 2.35 MB png file async loaded with js and it would greatly improve reaction box usability of pagure if the file get cached.

Last-Modified: Fri, 05 Oct 2018 12:48:07 GMT but I continue downloading it everyday :S

  • When do you need this? (YYYY/MM/DD)

Whenever is possible

  • When is this no longer needed or useful? (YYYY/MM/DD)

When pagure ends using this file for reaction emojis

  • If we cannot complete your request, what is the impact?

We'll continue downloading the same file time to time and that (in my case) supposes 3 secs of delay to show the reaction emojis on pagure instances


It can be done. For src it should be enough to edit proxy Varnish vcl file, while pagure.io will need a different solution because it's not behind proxies.

Metadata Update from @mizdebsk:
- Issue priority set to: Waiting on Assignee (was: Needs Review)
- Issue tagged with: easyfix, pagure, src.fp.o

6 months ago

This patch configures 1 month expire for that file.

From 8219d929be22f974a27d0a3c3583782ddf38a431 Mon Sep 17 00:00:00 2001
From: Alessandro Lorenzi <alorenzi@alorenzi.eu>
Date: Sun, 17 Mar 2019 11:43:48 +0100
Subject: [PATCH] Pagure: caching emojione

refs: #7629
---
 roles/pagure/frontend/templates/0_pagure.conf | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/roles/pagure/frontend/templates/0_pagure.conf b/roles/pagure/frontend/templates/0_pagure.conf
index 50c2d6e9b..42c3b4b65 100644
--- a/roles/pagure/frontend/templates/0_pagure.conf
+++ b/roles/pagure/frontend/templates/0_pagure.conf
@@ -78,6 +78,14 @@ WSGIDaemonProcess paguredocs user=git group=git maximum-requests=1000 display-na

   Alias /static /usr/lib/python2.7/site-packages/pagure/static/

+  <Directory "/usr/lib/python2.7/site-packages/pagure/static/vendor/emojione/">
+    <Files "emojione.sprites.png">
+      ExpiresActive On
+      ExpiresDefault "access plus 1 month"
+      Header append Cache-Control "public"
+    </Files>
+  </Directory>
+
   SetEnv GIT_PROJECT_ROOT /srv/git/repositories

   <Location />
@@ -145,6 +153,14 @@ WSGIDaemonProcess paguredocs user=git group=git maximum-requests=1000 display-na

   Alias /static /usr/lib/python2.7/site-packages/pagure/static/

+  <Directory "/usr/lib/python2.7/site-packages/pagure/static/vendor/emojione/">
+    <Files "emojione.sprites.png">
+      ExpiresActive On
+      ExpiresDefault "access plus 1 month"
+      Header append Cache-Control "public"
+    </Files>
+  </Directory>
+
   <Location />
     WSGIProcessGroup paguredocs
     <IfModule mod_authz_core.c>
@@ -182,4 +198,3 @@ WSGIDaemonProcess paguredocs user=git group=git maximum-requests=1000 display-na
   </Directory>

 </VirtualHost>
-
-- 
2.17.1

A month seems a bit long to me... how about 7 days?

src.fp.o is served by httpd and behind httpd/reverseproxy.

I've replicated the logic behind the expire.conf in fedoraproject.org

From c30c312430094dfd200dfbc591b9a480fe7ebf74 Mon Sep 17 00:00:00 2001
From: Alessandro Lorenzi <alorenzi@alorenzi.eu>
Date: Thu, 21 Mar 2019 23:56:39 +0100
Subject: [PATCH] Site src.fedoraproject.org expires

refs: #7629
---
 roles/fedora-web/src/files/expires.conf    |  5 +++++
 roles/fedora-web/src/tasks/main.yml        | 12 ++++++++++++
 roles/httpd/website/templates/website.conf |  5 ++++-
 4 files changed, 22 insertions(+), 2 deletions(-)
 create mode 100644 roles/fedora-web/src/files/expires.conf

diff --git a/roles/fedora-web/src/files/expires.conf b/roles/fedora-web/src/files/expires.conf
new file mode 100644
index 000000000..199080880
--- /dev/null
+++ b/roles/fedora-web/src/files/expires.conf
@@ -0,0 +1,5 @@
+<Location "/static/vendor/emojione/emojione.sprites.png">
+  ExpiresActive On
+  ExpiresDefault "access plus 1 week"
+  Header append Cache-Control "public"
+</Location>
diff --git a/roles/fedora-web/src/tasks/main.yml b/roles/fedora-web/src/tasks/main.yml
index d7616e84c..fbe8e87d1 100644
--- a/roles/fedora-web/src/tasks/main.yml
+++ b/roles/fedora-web/src/tasks/main.yml
@@ -19,3 +19,15 @@
   tags:
   - fedora-web
   - fedora-web/src
+
+- name: Copy some config files for {{website}}
+  copy: >
+    src={{item}} dest=/etc/httpd/conf.d/{{website}}/{{item}}
+    owner=root group=root mode=0644
+  with_items:
+  - expires.conf
+  notify:
+  - reload proxyhttpd
+  tags:
+  - fedora-web
+  - fedora-web/src
diff --git a/roles/httpd/website/templates/website.conf b/roles/httpd/website/templates/website.conf
index 2a6241a77..931655e6a 100644
--- a/roles/httpd/website/templates/website.conf
+++ b/roles/httpd/website/templates/website.conf
@@ -20,6 +20,10 @@
   Alias /static/hotspot.txt /srv/web/hotspot.txt
 {% endif %}

+{% if site_name == "src.fedoraproject.org" %}
+  Include "conf.d/src.fedoraproject.org/expires.conf"
+{% endif %}
+
 {% if sslonly %}
   RewriteEngine On
   RewriteCond %{REQUEST_URI} !/.well-known/acme-challenge/.*
@@ -85,4 +89,3 @@
   Include "conf.d/{{ site_name }}/*.conf"
 </VirtualHost>
 {% endif %}
-
-- 
2.20.1

Here the pagure.io conf with 1 week expire

From 4c01b9972d3961a87e364226d541fcbf5727ccc9 Mon Sep 17 00:00:00 2001
From: Alessandro Lorenzi <alorenzi@alorenzi.eu>
Date: Thu, 21 Mar 2019 19:46:54 +0100
Subject: [PATCH] pagure frontend: caching emojione sprites for 1 week

refs: #7629
---
 roles/pagure/frontend/templates/0_pagure.conf | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/roles/pagure/frontend/templates/0_pagure.conf b/roles/pagure/frontend/templates/0_pagure.conf
index 50c2d6e9b..87009fce0 100644
--- a/roles/pagure/frontend/templates/0_pagure.conf
+++ b/roles/pagure/frontend/templates/0_pagure.conf
@@ -78,6 +78,12 @@ WSGIDaemonProcess paguredocs user=git group=git maximum-requests=1000 display-na

   Alias /static /usr/lib/python2.7/site-packages/pagure/static/

+  <Location "/static/vendor/emojione/emojione.sprites.png">
+    ExpiresActive On
+    ExpiresDefault "access plus 1 week"
+    Header append Cache-Control "public"
+  </Location>
+
   SetEnv GIT_PROJECT_ROOT /srv/git/repositories

   <Location />
@@ -145,6 +151,12 @@ WSGIDaemonProcess paguredocs user=git group=git maximum-requests=1000 display-na

   Alias /static /usr/lib/python2.7/site-packages/pagure/static/

+  <Location "/static/vendor/emojione/emojione.sprites.png">
+    ExpiresActive On
+    ExpiresDefault "access plus 1 week"
+    Header append Cache-Control "public"
+  </Location>
+
   <Location />
     WSGIProcessGroup paguredocs
     <IfModule mod_authz_core.c>
-- 
2.20.1

in both scenarios is possible to set expire to the entire Location /static/

So, we are in freeze now, but this seems like a pretty straightforward change.

Would you care to mail the patches to the infrastructure list asking for a Freeze Break (there's a bunch of other examples on the list if you want to see the format).

Otherwise I can apply this after freeze.

Hi @kevin, I'll send the email later in the morning.

Applied. Many thanks!

:flower_playing_cards:

Metadata Update from @kevin:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

6 months ago

Login to comment on this ticket.

Metadata