U4-11074 - Optimisation - Allow caching of back office fonts

Created by Pete Duncanson 06 Mar 2018, 16:29:44 Updated by Sebastiaan Janssen 26 Aug 2018, 19:20:27

Tags: PR

Relates to: CON-1509

Subtask of: U4-11042

The back office fonts rarely change so it should be possible to cache them with a long cache time. This can bet setup by the end users/developer or we could just do this out the box.

On my test site I've got nearly 500kb of fonts used in the back office with no cache headers set (checked this on a production site too with the same result).

Suggest we just put a web.config file in the /Umbraco/assets/fonts folder which caches the fonts for 7 days? Editors who are in the back office day in day out should see a nice improvement by doing that while still allowing for new fonts via an upgrade to come through.

1 Attachments


Pete Duncanson 06 Mar 2018, 17:47:44

Submitted a PR https://github.com/umbraco/Umbraco-CMS/pull/2506

Pete Duncanson 07 Mar 2018, 10:53:39

There is an obvious grumble that might be raised with this one. "Wait! What about when upgrade? How do we invalidate the cache?"

Making sure the back office upgrades nicely and releases all the newly installed goodness to the user is super important and something I agree needs to be in the front of our minds when apply stuff like caching.

However, the fonts don't change. The file get added but those already added don't get updated. If you add a new font just include it and the caching will work as is in my PR. If you totally change all the fonts and with it the look and feel of the back office then that is a bigger change anyway. You could get around that but just renaming/moving the font folder.

Adding a complicated cache buster to this would be complication for the sake I think (in this instance) as the items in question are pretty static long term.

Pete Duncanson 12 Mar 2018, 15:04:35

I've been writing a blog post about this which raised some other possible issues. For testing this I used a different site to when I originally spotted in. I have a local copy of the site and the live version too. My local one has debug set to false and live has static file caching etc.

The original site I tested this on was "near to going live" but not live as yet as a result it didn't have static file caching etc. enabled. Once you have that install then you don't really need to cache these fonts with my fix and at that point in the blog post I thought it was a rubbish PR.

HOWEVER...on the bike ride home I thought about it some more. That sort of optimisation tends to only happen before go live. Which means up until that point no one has had cached fonts, editors have entered a tonne of content without this (modest) performance boost. Why should they wait? That wait might have been enough for them to think Umbraco is "slow" or lent wait to that perception. As a result I thought this mod was a good fix that we could add in now that would give everyone the benefits of this out of the box. Surely a good thing?

Sebastiaan Janssen 26 Aug 2018, 19:19:31

Agreed, these files change very rarely. The worst that could happen is that after an upgrade, the new font doesn't take effect for a few days.

Well the worst that WILL happen is that one day we'll update a font and at HQ we're all cursing because it doesn't update in the browser.

I just tested, dev tools open and empty cache & hard reload works, so I'm not too worried.

Priority: Normal

Type: Performance Problem

State: Fixed


Difficulty: Easy

Category: UI

Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.13.0


Story Points: