Improve stylesheet cacheing

Bug #1214124 reported by Kristina Hoeppner on 2013-08-19
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
High
Robert Lyon

Bug Description

There is no "purge the stylesheet cache" functionality in Mahara. This lack of functionality prevents stylesheet changes to be seen directly and generally, users will need to clear their browser cache.

Suggestion from Pace University:

Add a URL parameter for the version of Mahara in which the stylesheet changes.

So for example, instead of calling

     <link rel="stylesheet" type="text/css" href="/theme/raw/static/style/style.css">

consider calling the 1.7.1 stylesheet:

     <link rel="stylesheet" type="text/css" href="/theme/raw/static/style/style.css?v=1_7_1">

and in version 1.8.1 call:

     <link rel="stylesheet" type="text/css" href="/theme/raw/static/style/style.css?v=1_8_1">

So the stylesheet would be still be named style.css, but the URL parameter will prevent the browser from using a locally cached version.

Aaron Wells (u-aaronw) wrote :

This goes for all the static assets, actually: CSS, Javascript, pictures

summary: - Improve stylesheet catching
+ Improve stylesheet cacheing
Changed in mahara:
status: New → Triaged
importance: Undecided → High
milestone: none → 1.8.0rc1
assignee: nobody → Robert Lyon (robertl-9)
Robert Lyon (robertl-9) wrote :

Patch submitted:

The patch appends the release number to the urls for external javascript and css - allowing the browser to refetch them on update/upgrade

https://reviews.mahara.org/#/c/2431/

Changed in mahara:
status: Triaged → In Progress
Aaron Wells (u-aaronw) wrote :

Seems like a decent approach. The get_config('release') value goes up with each minor release, which is the most likely time that people will deploy new versions of Mahara. And in between minor releases, the version number gets changed to e.g. 1.7.3testing, which again is different, so if admins deploy a minor release and then update to HEAD before the next minor release, they'll get another version number.

I suppose if we want to be really complete on this, we should adopt a policy that if you push a commit that changes static assets, you should increment the release number e.g. 1.7.3testing1 1.7.3testing2, etc.

Aaron Wells (u-aaronw) wrote :

Actually on further reflection, I think maybe we should mimic the Moodle approach. What they do is store a separate arbitrary "themeversion" number. It gets incremented each time you upgrade, or if you push the "Purge cache" button on a special admin page. This allows the cache to be purged manually at any time, for instance if you deploy a change to one of your plugins.

Aaron Wells (u-aaronw) wrote :

On the other hand, if we don't have time to implement my idea, I'd be fine with deploying the patch that's based on minor release, for 1.8, and then implementing the purgeable one for a later release.

I second comment #5. The purge cache implementation would be more of a new feature and we are right before UI freeze...

Reviewed: https://reviews.mahara.org/2431
Committed: http://gitorious.org/mahara/mahara/commit/6764ecbfe85a6f87f73e0c2319d6ae57dc485930
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 6764ecbfe85a6f87f73e0c2319d6ae57dc485930
Author: Robert Lyon <email address hidden>
Date: Fri Aug 23 13:23:23 2013 +1200

Improving stylesheet + javascript file cache handling (bug #1214124)

- appending the release number to the url so that browsers will
fetch new version on update/upgrade

- urls for external js/css are now of the form [url]?v=[releasenumber]
- eg http://mahara.org/theme/views.css?v=1.7.2

Change-Id: I409746e8c60240c4da5db96fe16c93e8a2bd3dac
Signed-off-by: Robert Lyon <email address hidden>

Robert Lyon (robertl-9) on 2013-09-02
Changed in mahara:
status: In Progress → Fix Committed
Aaron Wells (u-aaronw) on 2013-09-30
Changed in mahara:
milestone: 1.8rc1 → 1.8.0
Aaron Wells (u-aaronw) on 2013-10-24
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers