I’m managing a website that is built from the ground-up in PHP and uses AJAX extensively to load pages within the site.
Currently, the ‘admin’ interface I created stores the HTML for each page, the page’s title, custom CSS for that page, and some other attributes in JSON in a file directory (e.g. example.com/hi would have its data stored in example.com/json/hi/data.json).
Is this more efficient (performance-wise) than using a database (MySQL) to store all of the content?
EDIT: I understand that direct filesystem access is more efficient than using a database, but I’m not just getting the contents of a file; I need to use json_decode to parse the JSON into an object/array first to work with it. Is the performance hit from that negligible?
Thad depends on what you use that data for.
If you only serve ‘static’ files, with almost the same data all the time, then even static HTML files are recommended for chaching.
If, on the other hand, you process data and display it in multiple forms (searches, custom statistics, etc) then it is much better to store it in some kind of DB