Skip to main content

How to Make PHP Website Run Faster

How to Make PHP Website Run Faster

Known fact that the loading speed of pages is an essential factor for every site. Users are not willing
to wait for the response of long pages and in the worst case, they can leave your site. Search engines
lower the page rank of your site when the speed is too low; This results in fewer visitors from
search engines. And yes, as a site administrator you will feel irritation if you have to wait a long time
to manage your site, knowing that this process can be speeded up. All ways to speed up your site
are divided into two basic methods: optimization of website software and optimization of server
software/hardware.
How to Make PHP Website Run Faster
Recently, the PHP department has developed several, highly loaded, PHP-based websites and
we want to share some techniques with which we can speed up sites, developed using the following
technologies/languages/tools: MySQL Percona Server,  PHP, JavaScript HTML5, Nginx, Apache,
FastCGI, APC. You can use the methods described in this article to speed up your PHP-based website
quickly and effectively, regardless of the platform (Yii, Symphony, Drupal, Joomla or any other - it doesn't matter).

Tips to optimize the performance of web applications

SQL requires optimization

Long processing of database queries is often the cause of the slow loading of pages. Often the reason
for this is the inaccuracy of writing searches, lack of competent indexing of tables, large and complex
requests and etc. At this stage, it is necessary to capture all requests that have executed more than
2 seconds and more often to the database have been forwarded.
You can handle requests that are too long by using the appropriate index settings in tables and
writing less bulky requests with all recommended SQL rules.
Cached data from the system from the database is the most effective way for most repeated questions.
It works like this - if one of the visitors has sent a query to the database that is returning some data,
this info will be taken out of the cache if the same query is run on the other user. This reduces the load
on the database and increases the loading time of the page.

Decreasing image size

You can often notice elements of slide shows on the main page of websites, where you will find 5-7 images of 300 KB each.
As a result, we have somewhere around 2MB, which is downloaded from the server to the user's browser.
If the website is a store and contains more than a thousand products, and each of these products contains
2-3 images (200-300Kb) on-page, all images require full loading time, which ultimately increases the page load time.
In this case, I propose:
Save the images as much as possible in JPG instead of in PNG format. Some would say that the quality
is lost, but sometimes it is not even striking, and with a large number of photos - that gives the result.
Change the compression of the image using special programs. So reducing the image quality by 10-15%
gives a major reduction in the image and visually you don't see the difference.
Tip: Instead of points 1 and 2, you can check each of your website URLs with Page Speed ​​Tools
because it reports how many bytes would be saved by optimizing the images of the page.
It is also attainable to compress images "on the fly" when getting them from server to browser. With GZIP you can
make it easy after a site connection and perform this task very efficiently

Caching

After these procedures, it is desirable to use one of the data cache systems. This allows you to store the
received data from the server in the browser cache for some time. With this method, you cannot take
data from the server after the page has been reloaded and use cached data from your browser.
It also reduces server load and reduces page load time.

Source code optimization

It is even one of the most important methods and perhaps one of the most labor-intensive.
Initially, correctly built system foundations provide reliability, errors, and speed of operations.
Every developer knows about it but often neglects this approach. The developers should initially use
object-oriented programming paradigms to obey Model-View-Controller and the like, as these become
truths for most modern web development software. In this early phase of software architecture,
errors in the future would entail significant labor costs.
Experts in PHP training in Chandigarh have extensive experience in developing fault-tolerant source
code, which is flexibly scaled and adapted to the unique needs of each customer. At the same time,
the software speed remains fast and the customer retains his ability to improve the system without having
to redevelop from scratch.
We want to name fast methods for source code optimization, which give the results in a short period of time:

1. Asynchronous javascript loading

This method is used when  you have on page:
  • Yandex and/or Google statistics or similar software that collects all visitor statistics from all your pages.
  • Online chat that uses JavaScript.
  • Different «share options» (share buttons: Facebook, Twitter, Linkedin, and others) that use JavaScript.
Often such JavaScript is loaded before the most important visual elements are displayed on the page and
the most important visual elements are only displayed when JavaScript has finished working. Because
JavaScript requires some time not to load significant visual content, it seems that the entire page is loading slowly.
In such cases you must use asynchronous JavaScript trays:
  • The first page loads visual objects (page layouts, styles, text, images), which is about 90-95% of the total visual content on the page;
  • JavaScript is only fully loaded on the "background" after the first point.
As a result, we receive a user-friendly page, because almost all content on the page is displayed without delay for the end-user

2. Correction of HTML, CSS, Javascript errors

To detect such errors, use W3C Validator online, which analyzes each site, identifies such errors and
explains what kind of error this is and how to fix it. With this method, you can quickly remove obvious
errors and in most cases, it helps to speed up the process of page loading. It also helps the search engines
to be more loyal to your website, which means that the rating of the site increases.

3. Reduction of page elements

When you load a page with products from a certain category, similar products and images are displayed in this list.
For example, you display 20-40 goods on the pagination list, which means that the exact number of images is also loaded.
In most cases, the page visitor cannot see all 20-40 items at the same time. To view them all, he must scroll with the mouse.
It follows that the first loading of 20-40 images takes a lot of time. And the visitor is bored to wait until these 20-40 photos are loaded on the page.
Possible solutions:
  • Load 6-12 elements for each category. In most cases this is the exact number of elements on a page;
  • Remove the following pagination type: «<<< 1 2 .... 56 57 >>>»;
  • Load 6-9 new items as far as you scroll with the mouse;
  • Place a vertical arrow in the lower right corner to return to the head of the page.

As a result, this method allows you to download data on-page, depending on user needs, reducing the load on the server
and freeing up system resources for other tasks.

Comments

Popular posts from this blog

The best PHP IDE development tools that every developer should explore

Best PHP IDE development tools that every developer should explore The best PHP IDE: Basically, to learn good programming skills in PHP or any other language, you must have known  the best PHP IDE, development tools or editors. There are many lists for PHP IDEs or code editors, but some of them are amazing and very useful for writing code. Basically, the best PHP IDE comes with many features and skills to do  things with the use of PHP programming support. PHP has many options in each field. It gives you the best. Therefore,  we want you to choose the best PHP IDE for your own operator. As always I used a line "Your life is your choice".  But I suggest you select better, Easy and Free. Read also: CMS or PHP framework How do we define a PHP IDE, PHP development tools or editors is the best? Basically, according to me, I have some parameters in which I select a PHP IDE or an editor that is listed below. Price (Free or Paid) Theme (color scheme) Snippets

Main update of the Cisco CCNA, CCNP, CCIE certification - Changes in 2020

Main update of the Cisco CCNA, CCNP, CCIE certification - Changes in 2020. In this post, you will learn about the main updates that will come to the Cisco Certification Program in February 2020 . CCNA training in Chandigarh blogger will explain exactly what the changes are, why Cisco has made them, how they affect you and what you should do if you are currently studying or You are considering starting to get a Cisco certification . Summary of the Main Changes The changes will take effect on February 24, 2020 All tracks and certification levels are affected The main levels of certification remain the same: CCNA, CCNP, and CCIE The different tracks are being eliminated at the CCNA level The tracks are consolidating at CCNP and CCIE level CCENT entry-level certification is being retired The recertification period for all certifications will be 3 years CCNA Cisco Certified Network Associate Current CCNA Tracks before February 24th: CCNA Routing and Switching CCNA C

What is PHP in Web Hosting?

What is PHP in Web Hosting? In this Article PHP training in Chandigarh provide the information about PHP in web hosting. PHP in web hosting is a server-side computer language used to arrange the display and functionality  of web pages. The term “PHP” is an abbreviation for the term “ PHP Hypertext Preprocessor .” The  PHP language is open source and free to use, not at all like proprietary web programming languages,  for example, ASP and C#. Proprietary languages must be interpreted by authorized server software,  For example,  Windows Server, whereas PHP keeps running on open source servers, such as  Apache. However,PHP can keep running on exclusive web servers too. PHP code pages can be  recognized by the ".php" file extension, according to PHP.net. A significant number of the open source web applications, for example, WordPress,  Joomla and  Drupal are written in the PHP language. Also, open source ecommerce packages like OSCommerce  and Zen Cart are c