I’m in the middle of moving away from PyroCMS to a custom solution built on Laravel. Wont go into the details as to why here, but it is a necessity.
I’m toying with the idea of caching things like pages and posts into flatfile once they are created, and then loading them (if they exist) and falling back to the mysql database if the cache isnt found.
It got me thinking. Is there a problem with essentially running the entire ‘frontend’ of your system or site on flatfile, pre-rendered cached files? Surely the cache only needs dropping/replacing when a post or page is modified, so a cache could essentially be kept for the lifetime of the site.
Unless I’m missing something, surely this is something that should be done a lot more, should it not? Even if it was just storing serialised or json data from the database tables, it’s got to be faster than opening up a mysql connection hasn’t it?
2
As per comments, before doing optimisations, you have to know which parts need to be optimised (measure). For static files, you can use reverse proxy. If latency is your problem, then moving files to a CDN might help with geographically distant clients. These optimisations will free you from programming, less code and even faster because they’re done even before php run.
Then for the dynamic parts you can cache as needed. One thing with using files is if in the future you want add more servers, accessing the cache files won’t be as ideal as using memcache, for example. Still worth doing on frontend, e.g. for showing data as user types.