Framing Pages - A just-in-time page generator #655
johanjanssens
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Framing Pages is not easy. Pages is not a static site generator and I personally don’t like the term SSG. It's too often mis-used. I more prefer the original terms, static web server and dynamic web server.
A static web server, or stack, consists of a computer (hardware) with an HTTP server (software). We call it "static" because the server sends its hosted files as-is to your browser.
A dynamic web server consists of a static web server plus extra software, most commonly an application server and a database. We call it "dynamic" because the application server updates the hosted files before sending content to your browser via the HTTP server.
Joomla is such extra software, originally we simply called it a dynamic web application, before the name CMS became a buzzy-word.
How is Pages different?
When Joomla serves a page it will dynamically generate the html from scratch, there is some caching in Joomla to try and make this process as fast as possible, but the page is always dynamically generated for each request.
With Pages that is no longer the case. Pages has a build in HTTP cache and it knows if the content used on the page is still valid (has not been changed) and will not re-generate the page if it doesn't need to, it will just serve it from cache. This makes Pages a lot faster out of the gate. As a nice bonus you also need a lot less server resources to power a site that uses Pages.
Pages does statically generate the html and stores it on disk but not as a flat html file, the cache is storing html, headers, page metadata and page validators. The validators contain the info Pages needs to decide to re-generate the page or to serve it from cache. This process is still dynamic and driven by PHP code. I therefor prefer to call this JIT (just-in-time) page generation.
Can Pages statically serve html?
Yes, since the v0.19 release Pages includes a static cache. The static cache allows Pages to cache the html as a flat file. Example how does looks for our own site.
With a few Apache rewrite rules Pages can serve this html statically. This doesn't make Pages a SSG, it makes it a lot smarter! You can configure per page how the cache works: static, dynamic or no cache at all. If there is no static file Apache will just forward the request to Pages,... and as you can see, this approach is not limited to html only, Pages can server rss, json, etc this way, you can even use it to build web API's, micro-services, etc.
The result of this is a best of all worlds. You get the benefits of a dynamic site, and benefits of a SSG, without any of the additional complexity, just a Joomla setup running on any web host.
How is this different from the Joomla Page cache
The Joomla Page cache plugin hasn't evolved much since we introduced it in Joomla 1.5. It offers a very basic approach to HTTP caching in Joomla. I never got the time to finish it and make it work properly before we rolled out 1.5 stable. HTTP caching and CDN's have also evolved quite a lot in the last few years with the revision of the HTTP 1.1 caching spec in 2014.
Pages is me trying to deal with some of those ghosts of the 1.5 days that still haunt me from time to time. Caching is one of them, routing is another...
I think I am coming pretty close to solving caching. Pages implements the complete HTTP/1.1 caching spec. If you unleash it's full power by enabling the http prefetcher Pages can get you 1ms page requests in the browser.
Beta Was this translation helpful? Give feedback.
All reactions