Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are many ways to skin a cat. Similarly there are many ways to achieve the same results you require.</p> <p>Some suggestions for "improving" IMO would be -</p> <p><strong>1. Fetching this data as pre-generated HTML with an AJAX call.</strong></p> <p>Using an AJAX call once the page is loaded, you could have your server build the HTML segments of your users activity feed. This will allow your page to load much faster and your content will be loaded shortly after. </p> <p>You don't even have to build HTML on the server - you could also pass a JSON object back from the AJAX call and build your HTML with JavaScript.</p> <p><strong>2. Creating a cached static HTML file of the users feed that is simply included into the markup.</strong> </p> <p>You could have your server generate all the HTML needed for a users feed at a certain interval - every 30 minutes for example - and then save that HTML into a file to be included in the existing HTML. You can do this using PHP's <code>include()</code> function. </p> <p>Using this method the activity feed will have a delay when refreshing so it might not be the best option - but if you make the interval smaller - every 5 minutes for example, you'll be saving a lot of calls to the DB.</p> <p>Check out <a href="http://en.wikipedia.org/wiki/Cron" rel="nofollow">cron jobs</a> - you could possibly use them to schedule the updates.</p> <p><strong>3. Place an <code>index</code> on the <code>user_id</code> field in your DB since you are using it to search by user.</strong></p> <p>This is a very important one especially if you are expecting many entries to exist in your DB. Placing an index on the fields that you use to search a table will vastly increase the performance of your queries. </p> <hr> <p>I'm sure there are many more things that can be suggested here.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload