What are the some good tricks to speedup your homepage?

There are several factors affecting your page speed. Some of them can be improved by tweaking some settings.

First of all we need to use the profiler app to analyze the problems. The profiler app gives us a lot of detailed information about the UNA pages.

When you see the details you will notice that there may be something to improve the page speed.

If you are having a lot of content for the visitors of your site in the home page, One important and may be less used method could be separating the homepages for members and visitors.
When you have the same home page and use the visibility options to show selected blocks to unauthenticated visitors and others to logged in members in fact the page is loading all. So if you have a lot of content in the visitors blocks this will still grap some important amount of time of the page loads for logged in members.
Lets go on real world examples:
I have 100 medical articles on the visitors index and this block is not shown to the logged in members. When I disable this block it saved me like 2 seconds from the total 5 seconds of server processing time reported by profiler.
So I created another home page for unauthenticated site visitors, put this block there. Logged in home page became lighter and dropped to 3 seconds for server proccessing.

As Alex explained I retested the above mentioned invisible block effect on loading times and yes it didnt effect the loading times.

Another issue I found with the help of profiler app was again releated to the  new posts galery view block which I locete on the right column of the page, it was showing only one new post (blog) and with the arrows you may see the others one by one. (I realized that this block was also loading the 100 blogs due to the settings to show how many blogs in different situations. So I disabled this block. And woooow see the results before and after:


Also notice that all the active modules are loaded they create mysql queries etc. so disable any module you dont use. Any block you left unused and invisible delete.

(Compare the query number of each measurement)
Now the logged in home page is loaded in less then 1 second :)

  • 2430
  • More
Replies (23)
    • Thank you Cem! The team will review your suggestions And I think it’d be great to put together a comprehensive speed improvement guide including advice like this. Will work on this over the coming weeks. 

      • will be great Andrew :)

        • We have been working a lot on the speed issues as well. In general una is quick and doesn’t generate any warning when google is checking it for mobile compatibility.

          like you we have discovered How much showcase and gallery views can delay loading. So we have reduced. The number of entries in the showcase we have on our front page.
          Q: is it possible to make lazy loading of the items not shown?

          we also use CDN (cloudflare) and caches the entire homepage permanently, which makes is very fast for first time visitors as well.
          we also removed the call to google ads in the header.

          optimising images and resizing them to the proper size gives a lot too

          All the best

          • When you have the same home page and use the visibility options to show selected blocks to unauthenticated visitors and others to logged in members in fact the page is loading all.

            Actually block isn't loading when visibility settings aren't allow to view the block, if you compare block generation time when it's visible and not visible then it will be big difference. It's still shown in profiler to show how much time is spent on checking visibility settings. So separating homepage for logged in and not logged in users works but the difference isn't significant.
            Thank you Cem for the great tips.

            • Some more tips to increase site load speed and speed score in google analytics

              1) disable 3rd-party copy&paste codes or at least use copy&paste code that can be inserted at the end of the page (before closing tag) instead of inserting it into tag

              2) don't install Fontawesome Pro module, it increases page load time by adding bigger font files, default free Fontawesome fonts aren't such big like Pro version

              3) use the latest PHP version, PHP 7.0 twice faster than PHP 5.6, PHP 7.2 faster than PHP 7.0 and 7.1, PHP 7.3 faster than 7.2 and 7.1, PHP 7.4 significantly faster than PHP 7.3, and of cause use PHP OpCache 

              4) enable Caches in UNA

              5) make number of items per page for Timeline as small as possible

              6) set cache control for 1 year instead of 30 days for files (mostly images) uploaded to UNA

              UPDATE `sys_objects_storage` SET `cache_control` = 31536000 WHERE `cache_control` = 2592000

              Then clear UNA DB cache

              • Try to play with Percona Toolkit. 

                • Hi Alex thanks for the explanation
                  yes I perceived wrong, I retested and the invisible block that I mentioned above doesnt effect that much the loading time.👍
                  The profiler results tricking me are as below,

                  1. What is the meaning of that X.X E-5sec, how shall we evaluate it?

                  2. The SQL query number of the logged in home page is changing from 4000 + to 15000+ queries which triples the loading time, I couldn't catch if a module is doing this, but is this normal or I should check more deeply?

                  PS: Later I found that the multifunctional create post block is creating the 10000+mysql queries.

                  • I noticed last day total query number on logged in homepage is very high even though Dbcache is active.
                    For several hours I was testing each module on and off (attention dont do this on your production server you will lose all settings additional menu items etc. attached to moıdule) to see if any of them may be creating the 10000+ sql queries on the logged in homepage. After hopeless attemps on modules.I started to test the page blocks, disabled all first and enabled one by one, leaving always one block in the page and after many tests I guess I found a bad boy:
                    Upon the report of the profiler while dbcache is enabled The multi functional create post block is doing almost 10000 queries alone in every page load which may take 1.8 seconds, this is more then all other 27 modules and 11 page blocks in my production server who creates a total of 5-6000 queries.)

                    The other simple post block is only ~1000 queries and 0,0019 seconds.

                    Here we have to consult Alex T⚜️ :
                    1. is this a normal behaviour or there is a bug with that block?

                    2. This block is not changing cant we cache this one? "Enable page blocks cache" is selected but in the profiler reports it says no blocks are cached, how can we make the blocks cached?

                    3. In the 4th picture the block is behaving normal . it happens like this:
                    Developer>Pages>Settings> Enable page cache (I used 60 seconds)
                    reload page a few times
                    page settings> Disable page cache = 0 seconds
                    Enable profiler
                    Reload page

                    after this sequence create post and create post public starts to behave normally. yet I couldnt catch with what they start to go to 10000 queries.

                    • Do you have any plans to upgrade the cloud server to PHP 7.4 from PHP:7.2.24 ?

                      • You say above "and of cause use PHP OpCache ". What is that and how do I enable it?

                        • In above #6... Can I add the line "UPDATE `sys_objects_storage` SET `cache_control` = 31536000 WHERE `cache_control` = 2592000"  to Designer  > head injections  ? Or should that lind be added some where else ?

                          • No no John these are database commands. Not for adding to head section.

                            Database commands are very sensitive you may easily break your site. Better to get professional help.

                            • Thought so. Thank you Cem 

                              • Do you have any plans to upgrade the cloud server to PHP 7.4 from PHP:7.2.24 ?

                                Yes, we preparing to run new cloud servers on Ubuntu 20.04 with PHP 7.4 

                                • I am still researching the above mentioned problemI, discovered that there is another block from time to time which behaves nasty. This routed me to causes other then Una.

                                   there is a probability that the extra queries may be caused by server configuration not related to Una.

                                  Alex T⚜️ 

                                  • Thank you Cem for your investigation. To generate this block several modules need to be loaded and different check need to be performed, this is the reason it generate so many queries. We'll have a look how this block loading speed can be improved or cached:

                                    • 1. What is the meaning of that X.X E-5sec, how shall we evaluate it?

                                      5 means how many numbers point should be moved to the left, for example 8.0E-5 sec means 0.00008 sec.

                                      • Thank you Alex

                                        • This is a great read about DB tuning and how we can speed up the site. Alternatively, I believe we can create a replica of the primary DB and make it READ ONLY, this way when folks come to my site mainly to browse around, they can be directed to the READ node instance, and users who write articles & blogs etc they can be directed to Read/Write instance.. I was wondering if this is doable, if so, how can we keep the 2 instances on both nodes in sync without manual replication.. Please keep in mind, I'd like to setup such a replication for performance purposes only and not necessary for DR. The failover is another subject.    
                                          Lastly, I was wondering if UNA compresses & optimizes pictures and mp4 Vids automatically when they are uploaded to the site ?  Thx.

                                          • Hello AJ Fariss !

                                            1) About the read and read & write databases - I guess this will not bring the big profits, requires to change the code and depends much more t=from the proper MySQL server setup.

                                            2) Yes, UNA compresses / resizes the pictures and videos for better "work" on the site.

                                            • Any good triсs to score homepage after login? Cem 

                                              • all above are for logged in homepage Rocco

                                                • Hi ... by clicking     there are errors comming :-(

                                                  Warning:  array_merge(): Expected parameter 2 to be an array, bool given in /home/unaio/public_html/modules/boonex/timeline/classes/BxTimelineTemplate.php on line 2566
                                                  Notice: unserialize(): Error at offset 195 of 289 bytes in /home/unaio/public_html/modules/boonex/timeline/classes/BxTimelineTemplate.php on line 561
                                                  Notice: unserialize(): Error at offset 195 of 289 bytes in /home/unaio/public_html/modules/boonex/timeline/classes/BxTimelineModule.php on line 4040
                                                  Notice: unserialize(): Error at offset 195 of 289 bytes in /home/unaio/public_html/modules/boonex/timeline/classes/BxTimelineTemplate.php on line 2566
                                                  Warning: array_merge(): Expected parameter 2 to be an array, bool given in /home/unaio/public_html/modules/boonex/timeline/classes/BxTimelineTemplate.php on line 2566

                                                  Login or Join to comment.