Our services
If you can think it, we can make it brainsoft.
If you can think it, we can make it brainsoft.
A content site with a few hundred pages does not need a global CDN to feel fast. What it needs is a cache in front of the app, sane compression, images that are not four megabytes each, and a way to check that none of it regressed. The CDN question usually comes up first because it is the easiest thing to buy, not the most effective thing to do.
Below is the setup I put in front of a typical WordPress or Rails or Django content site running on one VPS: Nginx as a caching reverse proxy, Brotli and gzip on, image resizing done at build or upload time, and a handful of headers that let browsers hold on to assets. It costs nothing beyond the server you already pay for, and it is the same shape of work we do in our services when a client wants speed before infrastructure spend.
Before touching config, load the site in a private window with the network panel open and look at three things: total transfer size, the waterfall gaps, and which requests are HTML documents rather than static files. On a content site the HTML is usually the slow part, because it is generated per request and never cached.
Run a quick check from the server side too, so you know how much time is PHP or Python versus network:
curl -s -o /dev/null -w '%{time_starttransfer} %{size_download}\n' \
https://example.com/some-article
If time to first byte is consistently above a few hundred milliseconds, caching the response is the highest-value change. If it is fast but the page still feels heavy, the problem is assets.
This is the part a CDN would normally do for you. Nginx can hold rendered pages in memory or on disk and serve them without waking the app. For anonymous content, that is almost always safe.
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=pages:64m
max_size=2g inactive=7d use_temp_path=off;
server {
location / {
proxy_cache pages;
proxy_cache_valid 200 10m;
proxy_cache_use_stale error timeout updating;
proxy_cache_bypass $cookie_session;
add_header X-Cache-Status $upstream_cache_status;
proxy_pass http://127.0.0.1:8080;
}
}
The X-Cache-Status header is the whole point. Hit a page twice and confirm you see HIT. If you never see it, check for Set-Cookie on the upstream response, which disables caching by default in many setups.
Turn on Brotli with gzip as fallback. Both are one module line each in modern Nginx builds, and they cut HTML and CSS transfer noticeably.
brotli on;
brotli_comp_level 5;
brotli_types text/html text/css application/javascript image/svg+xml;
gzip on;
gzip_types text/html text/css application/javascript image/svg+xml;
Images are where content sites lose the most weight. Generate the sizes you actually render at upload time, serve WebP, and set explicit width and height so the layout does not jump. A 1600px photo shown in a 720px column is wasted bytes on every visit.
Then give static files a long lifetime with a content hash in the filename, so you can cache them for a year safely:
location ~* \\.(css|js|woff2|webp)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
HTML itself should get a short lifetime, minutes rather than hours, so a cache purge is not the only way to fix a typo.
A cache config that works today will be undone by a plugin update, a new third-party script, or an editor uploading a 6 MB hero image. Put a small check in cron that fetches a few key URLs and logs size and timing, and alert when either jumps. That is cheaper and more honest than a dashboard nobody opens.
If you would rather have someone set this up and keep an eye on it, get in touch. The same techniques hold for a site on shared hosting; you just have less control over the proxy layer.
If most of your readers are in one region, a well-configured cache on your own server gets you most of the benefit. A CDN helps when readers are spread across continents or when you need to absorb traffic spikes you cannot serve from one machine.
Not if you bypass the cache when a session cookie is present and purge the affected URL after a new comment or post. Anonymous readers get the cached page; everyone else hits the app.
Compress images and enable text compression. Those two changes usually move the numbers more than anything else, and neither requires touching application code.