Some ways to optimize a website

Some ways to optimize a website

Ever since Google announced that the loading speed of a website would positively / negatively influence web positioning, many users have been asking us how they can optimize the performance of their websites to optimize this new point. In this article we will discuss various options and tricks to improve the loading of our website through the popular file .htaccess and without it.

Leverage Cache Browser

We start this post with the activation of Leverage Cache Browser. What does it mean? Well, Leverage Chache Browser is a small function for Apache that allows us to cache all the files that we specify from a website in the user’s browser. In this way, the first time that a user accesses the site, they are downloaded from our server, being stored on the user’s local disk, that is when the user re-enters the page, and all the requests to images, CSS, JS ‚Ķ That I had previously downloaded, now execute them from your disk, in this way we optimize the load and reduce the requests that the server receives, saving resources that can be used for a traffic spike, for example.Before discovering the code that provides us with this function, we have to check if our accommodation or dedicated server has the module (mod_expires) activated, if it does not have it we must ask our accommodation to install it for us, if possible. installed and properly configured by our hosting provider, we proceed to open the hidden .htaccess file that servers usually have using an FTP client. In the case of not having it, we must create one manually and upload it to the root folder of our server (/www). In the next step, we open this file with the notepad or any text editor and write the following code.

Once we have this code pasted in our .htaccess file, we proceed to upload it again and verify if our website works correctly or if the classic error 500 (Internal Server Error) appears, if this appears it means that the module is not activated or that We have left a space at the end of the document or, on the contrary, an invalid character. Also say that we can add more types of files in the sections we want.

Image optimization

This is an important point in order to improve speed. For this we can use online tools that perform these functions or, on the contrary, we can use desktop programs, such as GIMP or Photoshop. If we use the second measure, we can do it in several ways, or by reducing its quality, eliminating data, reducing the color palette, changing the format, among other possibilities. Another point to highlight of this topic is that our images should not weighing more than 50 KB, if they exceed this size, the web becomes quite slow since it increases the download time by the number of images we have. I personally use the system of Gtmetrix which provides you with a copy of the image of your website but already optimized, in this way I save a lot of time at this point. To use the service, we just have to write the address of our website, wait for it to analyze and search in PageSpeed ‚Äč‚Äč(Optimize Images), there will appear in a list mode all our images that we need to optimize, download and download them. we re-raise to our directory where they are hosted.

Using a CDN (Content Delivering Network)

If our website uses many images, one of the best improvements that you can make on your websites is to insert a CDN, basically what this service will do is manage the images from another server, in this way the images are downloaded in parallel increasing with it an improvement in user navigation.There are popular services for this type of service, such as Amazon’s S3, which we recommend for its excellent system and support.

Minimize DNS

At this other point, we found the possibility of improving the performance of our website by 25%. This is achieved because thanks to the elimination of external DNS, such as scripts to external services (Bars, analytics, Adsense), in this way when the user tries to load the website, they will not have to wait for the website to load, the service, the other service, and dozens of other scripts It is evident that there is DNS that is not necessarily strict to eliminate, for example if we use advertising from an external platform (Adsense), but if it is necessary, such as if we use a script that we only use in the administration area, or in a specific page, and it is being loaded in the whole website, to add an example.

Enable GZIP / Deflate compression

This is a very important section regarding the performance of our server and consumption, in addition to the loading speed. The use of the Gzip technology allows us to compress the files, thus subtracting http packages and consuming much less transfer. To activate this technology, we can do it through the htaccess file, for this we open the document and write the following code:

What does this code mean? This code: AddOutputFilterByType DEFLATE text / xml means that the text and xml documents will be compressed before sending them over the network and that the user receives them, it uses the Deflate technology which is an improvement of the GZIP that currently 90% of browsers support it (IE, Chrome, Safari, Opera, Mozilla). Therefore, a great improvement for our website that our users will surely notice. Finally, it must also be said that it may increase the consumption of resources a little, but most likely we will not notice it.

Size reduction in CSS, JS and HTML

To reduce the size of these files, the best we can do is eliminate all the comments that these documents have or reduce the expressions as much as possible, in this way we will save a few tens of KB which will help us reduce the load.You can use services in line (MinifyCSS | Minify JS | HTML Minifier) ‚Äč‚Äčto perform these operations or manually with a normal text editor.

Using the Footer

Using the footer to increase the performance of a website is one of the best practices we can do, since the first thing that will load will be our website, in this way the user will see the content and while reading the rest of the files will be loaded of the footer. Typically, files that are placed before the label