Fossil Forum

Optimizing Fossil web responses
Login

Optimizing Fossil web responses

Optimizing Fossil web responses

(1) By Warren Young (wyoung) on 2018-09-12 14:36:17 [source]

Now that the default skin has a large chunk of static JS code in the footer due to the newly-merged hamburger menu sitemap feature, it's time to revisit this topic.

Extract Inline JS

That JS code should be served as a pseudo-file from Fossil, not inline on each page. Between this and the following advice, the cost of that new code will be lower when paid, and it'll be paid much less often.

Cache Static Web Assets

fossil-scm.org is currently not allowing the browser to cache favicon.ico for long durations according to WPT. Basically, you want the server to return a far-future Expires header for such files, so it doesn't have to do an HTTP round trip to verify that its cached version is still valid. Since that one file is the only static asset on that page, it gets a failing grade on that score, being 100% failure.

The web server on fossil-scm.org should also set far-future expire times for *.css, *.js, *.png, *.jpg...

Versioning

If you simply set far-future Expires headers on static asset files, you require the user to do a cache-less reload (e.g. Cmd-Shift-R in Chrome on macOS) or toss their browser cache any time one of these files change.

The standard way to avoid that requirement is to change the file name any time the content changes. For Fossil-managed resources, this is mostly easy: instead of serving tree.js from /dir?type=tree, it should serve tree-19997e99c4.js, that being the artifact prefix for the trunk version of src/tree.js. You could do it with a query parameter instead, if you prefer: tree.js?uuid=19997e99c4.

This gets a bit tricky with inline JS that depends on TH1-substituted values, as with the new skins/default/js.txt. One way around it would be to add a hash for the variable name(s) and value(s) substituted into the script, so if either changes, the file name changes, so the browser will fetch a new copy: skin.js?uuid=abcd1234&vars=ef5678ab.js.

Minify JS and CSS

Whitespace and comments should be squished from served JS and CSS, at the least.

Better would be to embed Douglas Crockford's jsmin.c into Fossil, which has a BSDish license. And something similar for CSS as well, of course.

Gzip compression helps, but it's better if you gzip minified text.

First Byte Time

The other problem pointed out by WPT is the first byte time for the main fossil-scm.org/fossil page.

I suspect part of the reason we got a C grade for this is that fossil-scm.org is using CGI, which adds a program launch and SQLite DB open to the front of every call. Contrast the result for the same page on the MySQL++ site which returned its result a few hundred ms faster.

Part of this must also be that the sqlite.org VPS is busier. But then, it's probably running on a beefier VPS than tangentsoft.com.