I am almost done building a WordPress website, and the main issue holding up from launching is the very long times it is taking to execute user queries.
I have enabled cacheing in browser, and in php, and gziping, as well as using W3 Total cache plugin, and tried various other caching plugins with marginal success.
Also have raised the timeout time and memory in php.ini and wp-config.
The main page I am having an issue with is http://www.qbhitlist.com/qbhitlist/quarterbacks/ but the home page, and the other two ranking pages are slow as well.
http://www.qbhitlist.com/qbhitlist/rankings/qbhl-top-50/
http://www.qbhitlist.com/qbhitlist/rankings/qbhl-premium-player-rankings/
I understand why (querying over 7000 users) but there is no way around doing that, that I am aware of.
So is there a way to possibly save the main query to a json file, or global array, or lazyload the query after the page has loaded? Or any other solution that would drastically decrease the page load time / improve performance.
Any advice would be greatly appreciated.
You are doing it wrong. You should not dump all that data on a single page at once like that.
Even if you got to reduce the load time and put the site live, you would have to many queries hitting the database as soon as the number of concurrent users goes up. My guess is that the database would not handle such traffic.
Try to save the query in an intermediary table that you have more control over and get the data in bits. Display the first 50 items then link to the next 50 items use ajax or regualar pagintation without ajax and the load time will come down and you will not have issues when the site is live.
You can store the html in a transient. Set the expiration to
0
and delete the transient programmatically every time you update the list, so it gets regenerated.Sample code:
Transients are stored in the wp options table. Read more about the Transients API here.