Website Optimization Measures, Part IX
Post from November 14, 2019 (↻ August 10, 2021), filed under Web Development.
Welcome to another post in a long-standing series of random acts of website optimization, acts that are inspired by the work I’m performing on my own sites. Given the various activities needed to operate websites I often forget documenting improvements for this series, however this is what stood out over the last few months.
Improving server-side compression and caching. I’ve just cussed that I didn’t take notes about the exact optimizations. As far as I recall it was mostly about adding to what’s going to be compressed, and what’s going to be cached for how long, likely resulting in the following lines for my Apache setups:
The very short story for the relatively short caching periods: For smaller projects I’m still passionately skeptical about “versioning.”
Setting up content security policies (CSPs). The most advanced project to do this for was certainly this very site, leading to the following .htaccess line:
Header always set Content-Security-Policy "default-src 'self'; img-src 'self' *.amazon.com *.buysellads.net *.creativecommons.org *.doubleclick.net *.eyeem.com *.met.vgwort.de *.tumblr.com *.w3.org; script-src 'self' cdn.carbonads.com srv.carbonads.net; style-src 'self' 'unsafe-inline' *.w3.org"
Removing Web Sign-In markup. I like the ideas for and people behind the IndieWeb but playing with some of the markup, I found it didn’t add enough value. I removed it.
Updating http links to https. I connected routine link checks with this little performance (skipping a http–https redirect) and security improvement (ensuring a more secure connection in absence of HSTS and redirects). This one has greatly benefited the users of UITest.com.
&entity references. Escaping
&is rarely necessary anymore, and I replaced most
&. Upgrade Your HTML has a short chapter about the topic.
Implementing feature policies. I played with feature policies and found I could just block some more invasive features for my websites, features I wouldn’t want to make use of anyway:
Header always set Feature-Policy "camera 'none'; geolocation 'none'; microphone 'none'; payment 'none'"
Do you have a nicer standard setup?
Converting GIFs to PNGs. You get better compression results with PNGs than with GIFs and for some reason I still had a few GIFs hanging around in live projects. I converted and compressed that remainder in a swift manual operation using Preview/GIMP and ImageOptim.
Dropping ISBNs from paths (and obeying proper ISBN formatting). 14 years ago I had this idea that I should include (alas falsely formatted) ISBNs in the paths of my German book pages. That tradition held until a few weeks ago, when I learned about the correct formatting for ISBNs but decided that book names were far better (SEO, independence of identifiers) for the respective pages’ URL slugs than these numbers.
This is a part of an open article series. Check out some of the other posts!
I’m Jens Oliver Meiert, and I’m an engineering manager and author. I’ve worked as a technical lead for Google, I’m close to the W3C and the WHATWG, and I write and review books for O’Reilly. Other than that, I love trying things, sometimes including philosophy, art, and adventure. Here on meiert.com I share some of my views and experiences.
If you have questions or suggestions about what I write, please leave a comment (if available) or a message.
Have a look at the most popular posts, possibly including:
Looking for a way to comment? Comments have been disabled, unfortunately.
Perhaps my most comprehensive book: The Web Development Glossary (2020). With explanations and definitions for literally thousands of terms from Web Development and related fields, building on Wikipedia as well as the MDN Web Docs. Available at Apple Books, Kobo, Google Play Books, and Leanpub.