3 ms·
There is always a trade-off between static and dynamic content. Serving static articles out of a database is always going to have vastly lower performance than
by AndrewStephens 6y ago
There is always a trade-off between static and dynamic content. Serving static articles out of a database is always going to have vastly lower performance than generating the page at the time of authorship and setting long cache expiry times.
The problem with long cache times is that then some readers might see an out-of-date version of your page. I would argue that that is a small inconvenience to avoid no readers being about to see your article at all.
I know there are a lot of WordPress plugins that effectively generate the pages ahead of time and just serve those. I think perhaps that should be the default way WordPress works, at least for single articles. There is little gain in generating the whole page on every hit and everything to lose.
- rapind 6y agoI like varnish for this. You can set a small cache TTL (like 30 seconds) so it only let’s one request through per TTL (30 seconds). And with varnish even if you get 10k hits right when the cache is stale, it can be configured to only process the first request and serve the stale cache to the rest. Using a TTL isn’t great if you have a long tail of content, but pretty awesome if it’s a limited surface area that’s taking the load even if your dynamic backend is something heavy like Wordpress.
- moviuro 6y ago> The problem with long cache times is that then some readers might see an out-of-date version of your page. I would argue that that is a small inconvenience to avoid no readers being about to see your article at all. Aren't ETags exactly meant for that though? https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ET...
- AndrewStephens 6y agoETags are really aimed at a different problem, where an end-user/client wants to refresh content that they already have. They can help let a intermediate cache know that content has been updated, but the cache has to be configured to ask for it. Plus, for dynamic content even the cost of calculating the Etag is not zero.