G avatar

Using serverside compression to improve Tiddlywiki load time

elguille

Published: 20 Dec 2017 › Updated: 20 Dec 2017Using serverside compression to improve Tiddlywiki load time

Using serverside compression to improve Tiddlywiki load time

I have a tiddlywiki nodejs service running in my personal server in order to manage my notes anywhere. Tiddlywiki has easily become part of my daily life and has come to replace propietary software that compromises my privacy like google docs. However, it is quite risky to run your own services because you must maintain you server updated and be aware of the latest vulnerabilities, so in terms of usability, a propietary software might just be better because it would just work. But for those of us that like to just DIY, TW is a great tool that can be self hosted.

After installing some plugins and themes and adding some notes, my tiddlywiki notebook has grown to about 5 MB. Sometimes loading time for this is a bit slow, of about 23 seconds or so in a normal connection and some more with mobile internet. Now, this is not that much, I mean, I can wait a few seconds without dying. But since we live in a fast changing environment rushing through life just to go online and get stuff done, I figured I could lower this time by putting this service behind nginx so it is compressed on the server side.

image.png

So doing some research, I found this nginx module that does compression.

I added the following server configuration:

server {
     listen 1234;
     location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:1005;
        gzip            on;
        gzip_proxied    expired no-cache no-store private auth;
     }
}

I had to do some proxy configuring with proxy_set_header and proxy_pass so it copies the connection remote address (this is the client) and the host name to the local host address. Since we are using a proxy configuration and it handles basic authentication, I've added gzip_proxied with some options that avoids the content to be cached.

By doing this I managed to improve loading time to about 6 seconds, which is a big difference.

image.png

Next thing I want to do with this is to put a SSL certificate and enable the secure http protocol by using letsencrypt.



Posted on Utopian.io - Rewarding Open Source Contributors

Leave Using serverside compression to improve Tiddlywiki load time to:

Written by

Read more #utopian-io posts


Best Posts From G

We have not curated any of elguille's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From G