title: PHP include or MySQL fetch
body: <p>I have a basic learning site and on the navigation bar there is a category list (in form of tree, like main categories and their children) with around 30+ categories, which may increase, but not by much.</p>
  
  <p>On every page I retrieve them from the database, then using PHP I do a tree like calculation to order them into a tree (parent, then children).</p>
  
  <p>I feel like it's unnecessary to do it every time, so I want to cache it. But it's only like 30 or maximum 100 categories, so is it worth it to cache them?</p>
  
  <h2>So I want to know which of these methods is faster:</h2>
  
  <ol>
  <li>Get them from MySQL and then do a calculation in PHP</li>
  <li>Do step ( 1 ) once, each time a category is deleted, added, or updated, and store the result in an HTML file. Then every other time a page is loaded the app will check and include the file if it exists, or do step ( 1 ) again.</li>
  </ol>
  
  <p>Note: Every time a category is deleted, added, or updated, the cache file is deleted.</p>