{"id":20,"date":"2025-04-12T11:44:29","date_gmt":"2025-04-12T06:14:29","guid":{"rendered":"https:\/\/googiehost.com\/ambi\/?p=20"},"modified":"2026-02-21T22:31:21","modified_gmt":"2026-02-21T17:01:21","slug":"wordpress-speed-optimization","status":"publish","type":"post","link":"https:\/\/googiehost.com\/blog\/wordpress-speed-optimization\/","title":{"rendered":"WordPress Speed Optimization by 200% using .htaccess [No Plugin 2026]"},"content":{"rendered":"\n<p>After you\u2019re done putting on good quality content on your website and have made it eye-catching and attractive, you have to know it is not everything. <\/p>\n\n\n\n<p>After SEO consideration and working on the website&#8217;s layout, your website should be fast enough for the users to actually visit once it ranks on search engines.<\/p>\n\n\n\n<script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-3431396059777650\"\n     crossorigin=\"anonymous\"><\/script>\n<!-- blog380 -->\n<ins class=\"adsbygoogle\"\n     style=\"display:block\"\n     data-ad-client=\"ca-pub-3431396059777650\"\n     data-ad-slot=\"5496529093\"\n     data-ad-format=\"auto\"\n     data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<div class=\"acf-cta-block\">\n    <div class=\"acf-cta-content\">\n                                \n                            <div class=\"acf-cta-description\">\n                    <p>We recommend you use LiteSpeed-powered Shared or VPS hosting for better WordPress loading time. LSCache is 10X faster than any other cache available on WordPress Store.<\/p>                <\/div>\n            \n                            <a href=\"https:\/\/googiehost.com\/blog\/best-litespeed-hosting\/\" class=\"acf-cta-button primary\">\n                    7 Best Litespeed Hosting Providers!                <\/a>\n                        <\/div>\n<\/div>\n\n\n\n<p>It doesn\u2019t matter which kind of web hosting you are using <a href=\"https:\/\/googiehost.com\/blog\/best-shared-web-hosting\/\" target=\"_blank\" rel=\"noreferrer noopener\">Shared<\/a> or <a href=\"https:\/\/googiehost.com\/blog\/best-vps-hosting\/\" target=\"_blank\" rel=\"noreferrer noopener\">VPS<\/a>. In both servers,&nbsp;.htaccess commands have its own important contribution which can impact your <strong>WordPress Speed Optimization<\/strong> and many other things. <\/p>\n\n\n\n<p>Such as speeding up your blog, enabling cache, redirection of the domain name, and much more.<\/p>\n\n\n\n<p>You\u2019ve to strive to get your site loading in less than two seconds to impress the users and the algorithm Google uses. One of the ways to optimize your site is through the .htaccess file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"wordpress-speed-optimization-plugins\">WordPress Speed Optimization Plugins<\/h2>\n\n\n\n<p>There are some plugins that can improve your WordPress website or blog loading speed but before you install any plugin you must understand what plugin will work for your depending on your <strong>Hosting Environment<\/strong>&#8230;<\/p>\n\n\n\n<p><strong>LiteSpeed Plugin<\/strong><\/p>\n\n\n\n<p>LiteSpeed WordPress Plugin built to speed up your website loading speed hosted on <strong><a aria-label=\" (opens in a new tab)\" class=\"rank-math-link\" href=\"https:\/\/googiehost.com\/blog\/best-litespeed-hosting\/\" target=\"_blank\" rel=\"noreferrer noopener\">LiteSpeed webserver<\/a><\/strong> however you can use this plugin if you are hosted on a standard Apache server but the cache wouldn&#8217;t be working perfectly.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><a href=\"https:\/\/googiehost.com\/blog\/wp-content\/uploads\/2023\/02\/LiteSpeed-Plugin.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"541\" src=\"https:\/\/googiehost.com\/blog\/wp-content\/uploads\/2023\/02\/LiteSpeed-Plugin.png\" alt=\"LiteSpeed Plugin\" class=\"wp-image-1000061322\" title=\"\" srcset=\"https:\/\/googiehost.com\/blog\/wp-content\/uploads\/2023\/02\/LiteSpeed-Plugin.png 1024w, https:\/\/googiehost.com\/blog\/wp-content\/uploads\/2023\/02\/LiteSpeed-Plugin-300x158.png 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>It has an inbuilt Cache, CDN, and image optimization so you don&#8217;t really need to install multiple plugins for separate tasks. Most <a href=\"https:\/\/googiehost.com\/blog\/best-free-web-hosting\/\" target=\"_blank\" rel=\"noreferrer noopener\">hosting providers<\/a> offer LS Webserver hosting so because you need to install this plugin you should ask your hosting provider which web server they are using.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"whats-a-htaccess-file\">What\u2019s a .htaccess file?<\/h2>\n\n\n\n<p> It is a configuration file. .htaccess file is used by Apache web servers found in the root directory.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"what-does-htaccess-file-do\">What does .htaccess file do?<\/h2>\n\n\n\n<p>It is the key to controlling a particular folder or a piece of the server. .htaccess is very useful to edit the configuration of the server software resulting such as starting or pausing some features or functionality of the server. <\/p>\n\n\n\n<p>To name a few, one can create diversions or password-protected directories, block specific IPs, improve page loading speed, and optimize the site.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"locating-htaccess-file-in-wordpress\">Locating .htaccess file in WordPress<\/h3>\n\n\n\n<ul class=\"wp-block-list is-style-checked\">\n<li>Assuming your WordPress site has generated a .htaccess file, it must be located in the root folder of the installation.<\/li>\n\n\n\n<li>.htaccess file is a hidden file so make sure to \u2018show hidden files\u2019 when you\u2019re using cPanel or FTP client.<\/li>\n<\/ul>\n\n\n\n<p>This file can be accessed under this location easily and \u201c<strong>username<\/strong>\u201d will be the first 8 characters of your primary domain name.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><a href=\"https:\/\/googiehost.com\/blog\/wp-content\/uploads\/2023\/02\/Locating-.htaccess-file-in-WordPress.png\"><img loading=\"lazy\" decoding=\"async\" width=\"641\" height=\"415\" src=\"https:\/\/googiehost.com\/blog\/wp-content\/uploads\/2023\/02\/Locating-.htaccess-file-in-WordPress.png\" alt=\"Locating .htaccess file in WordPress\" class=\"wp-image-1000061324\" title=\"\" srcset=\"https:\/\/googiehost.com\/blog\/wp-content\/uploads\/2023\/02\/Locating-.htaccess-file-in-WordPress.png 641w, https:\/\/googiehost.com\/blog\/wp-content\/uploads\/2023\/02\/Locating-.htaccess-file-in-WordPress-300x194.png 300w\" sizes=\"auto, (max-width: 641px) 100vw, 641px\" \/><\/a><figcaption class=\"wp-element-caption\">\/home\/username\/public_html<\/figcaption><\/figure>\n\n\n\n<p>By default, .htaccess file is hidden due to some security reasons so you wouldn\u2019t be able to see it under the public_html directory until you make it visible manually. For that:<\/p>\n\n\n\n<script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-3431396059777650\"\n     crossorigin=\"anonymous\"><\/script>\n<!-- blog380 -->\n<ins class=\"adsbygoogle\"\n     style=\"display:block\"\n     data-ad-client=\"ca-pub-3431396059777650\"\n     data-ad-slot=\"5496529093\"\n     data-ad-format=\"auto\"\n     data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<ul class=\"wp-block-list is-style-checked\">\n<li>Go to\u00a0<strong>Settings\u00a0<\/strong>and<\/li>\n\n\n\n<li>Tick\u00a0<strong>Show Hidden Files (dotfiles)<\/strong><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><a href=\"https:\/\/googiehost.com\/blog\/wp-content\/uploads\/2023\/02\/Tick-Show-Hidden-Files-dotfiles.png\"><img loading=\"lazy\" decoding=\"async\" width=\"591\" height=\"378\" src=\"https:\/\/googiehost.com\/blog\/wp-content\/uploads\/2023\/02\/Tick-Show-Hidden-Files-dotfiles.png\" alt=\"Tick\u00a0Show Hidden Files (dotfiles)\" class=\"wp-image-1000061325\" title=\"\" srcset=\"https:\/\/googiehost.com\/blog\/wp-content\/uploads\/2023\/02\/Tick-Show-Hidden-Files-dotfiles.png 591w, https:\/\/googiehost.com\/blog\/wp-content\/uploads\/2023\/02\/Tick-Show-Hidden-Files-dotfiles-300x192.png 300w\" sizes=\"auto, (max-width: 591px) 100vw, 591px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"if-you-cant-find-htaccess-file\">If You Can\u2019t Find .htaccess file<\/h3>\n\n\n\n<p>This might be the reason, the concerned site has not generated a .htaccess file yet.<\/p>\n\n\n\n<p>Set up permalinks to generate a .htaccess file:<\/p>\n\n\n\n<ul class=\"wp-block-list is-style-checked\">\n<li>Go to settings<\/li>\n\n\n\n<li>Go to permalinks settings and click on save changes.<\/li>\n<\/ul>\n\n\n\n<p>This should work. Alternatively, you can create a .htaccess file and upload it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"before-you-optimise-your-site-via-htacess\">Before You Optimise your site Via .htacess<\/h3>\n\n\n\n<ul class=\"wp-block-list is-style-checked\">\n<li>Stop the plugins from creating any cache and get rid of the cache produced earlier by the plugins.<\/li>\n\n\n\n<li>Check that your website is in a working state. Fix errors, if any.<\/li>\n\n\n\n<li>Get an approximate idea of page loading time.<\/li>\n<\/ul>\n\n\n\n<div id=\"callout-block_bbaeef44e3ec8e406e3dd1696df2ffdd\" class=\"acf-callout has-label\" style=\"background-color: #fff3e0; color: #e65100; border-color: #ff9800;\">\n        \n            <div class=\"acf-callout-label\">Warning<\/div>\n    \n    <div class=\"acf-callout-content\">\n        <div class=\"acf-innerblocks-container\">\n\n<p>Always back up your existing .htaccess file before making any changes. A small syntax error can take your entire site offline. Download a copy via FTP or your hosting file manager first.<\/p>\n\n<\/div>\n    <\/div>\n\n    <\/div>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"speeding-up-your-page-using-htacess\">Speeding Up Your Page Using .htacess<\/h3>\n\n\n\n<p>Decreasing the page loading time is a multi-step process and there are a few features you need to enable or disable. After doing a little research, here is the list of the most effective set of configurations most developers will recommend.<\/p>\n\n\n\n<ul class=\"wp-block-list is-style-checked\">\n<li><strong>Enable Gzip and Deflate Compression<\/strong><\/li>\n\n\n\n<li><strong>Enable Browser Caching<\/strong><\/li>\n\n\n\n<li><strong>Enable Keep-Alive<\/strong><\/li>\n\n\n\n<li><strong>Disable Image Hotlinking<\/strong><\/li>\n\n\n\n<li><strong data-rich-text-format-boundary=\"true\">Enable mod_pagespeed<\/strong><\/li>\n<\/ul>\n\n\n\n<p><strong>Let us learn about all these steps one by one.<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"gzip-and-deflate-compression-speeding-up-wordpress-site-using-htaccess\">Gzip And Deflate Compression Speeding Up WordPress Site Using .htaccess<\/h3>\n\n\n\n<p><em>Compression merely reduces the size of the document, best recommended for XML files, JavaScripts, CSS stylesheets, and also HTML files. Did you know that compression reduces the data to 60 to 80%?<\/em><\/p>\n\n\n\n<p>The first thing is enabling compression, of course.<\/p>\n\n\n\n<p>The two good ways to enable compression are through mod_gzip or mod_deflate if you\u2019re using Apache[1]&nbsp; Software. Mod_deflate is a little easier one, but there are chances your website or server doesn\u2019t support it. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"deflate-compression\"><strong>DEFLATE Compression<\/strong><\/h4>\n\n\n\n<script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-3431396059777650\"\n     crossorigin=\"anonymous\"><\/script>\n<!-- blog380 -->\n<ins class=\"adsbygoogle\"\n     style=\"display:block\"\n     data-ad-client=\"ca-pub-3431396059777650\"\n     data-ad-slot=\"5496529093\"\n     data-ad-format=\"auto\"\n     data-full-width-responsive=\"true\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<pre class=\"wp-block-code\"><code># BEGIN DEFLATE COMPRESSION\n&lt;IfModule mod_deflate.c&gt;\n# Compress HTML, CSS, JavaScript, Text, XML and fonts\n AddOutputFilterByType DEFLATE application\/javascript\n AddOutputFilterByType DEFLATE application\/rss+xml\n AddOutputFilterByType DEFLATE application\/vnd.ms-fontobject\n AddOutputFilterByType DEFLATE application\/x-font\n AddOutputFilterByType DEFLATE application\/x-font-opentype\n AddOutputFilterByType DEFLATE application\/x-font-otf\n AddOutputFilterByType DEFLATE application\/x-font-truetype\n AddOutputFilterByType DEFLATE application\/x-font-ttf\n AddOutputFilterByType DEFLATE application\/x-javascript\n AddOutputFilterByType DEFLATE application\/xhtml+xml\n AddOutputFilterByType DEFLATE application\/xml\n AddOutputFilterByType DEFLATE font\/opentype\n AddOutputFilterByType DEFLATE font\/otf\n AddOutputFilterByType DEFLATE font\/ttf\n AddOutputFilterByType DEFLATE image\/svg+xml\n AddOutputFilterByType DEFLATE image\/x-icon\n AddOutputFilterByType DEFLATE text\/css\n AddOutputFilterByType DEFLATE text\/html\n AddOutputFilterByType DEFLATE text\/javascript\n AddOutputFilterByType DEFLATE text\/plain\n AddOutputFilterByType DEFLATE text\/xml\n&lt;\/IfModule&gt;\n# END DEFLATE COMPRESSION<\/code><\/pre>\n\n\n\n<p>If the\nconcerned website isn\u2019t supporting deflate, GZIP is your key.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"enabling-gzip-using-htaccess-commands\">Enabling GZIP using&nbsp;.htaccess&nbsp;commands<\/h4>\n\n\n\n<p>By&nbsp;enabling GZIP for your blog or website&nbsp;you may increase its loading time up to 30-50% faster This will help your website retain visitors and improve page opinions. <\/p>\n\n\n\n<p>Not only for a <a href=\"https:\/\/googiehost.com\/blog\/best-nvme-hosting-provider\/\" target=\"_blank\" rel=\"noreferrer noopener\">fast-loading site<\/a>, but it\u2019s also always recommended to compress your HTML for the site.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"setting-gzip-using-htaccess-commands-on-the-apache-server\">Setting GZIP using&nbsp;htaccess&nbsp;commands on the Apache server<\/h4>\n\n\n\n<p>Most of you using an apache server for web hosting service can directly follow our instructions and turn on&nbsp;<strong>GZIP<\/strong>&nbsp;by adding a few deflate codes to your .<strong>htaccess<\/strong>&nbsp;file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># compress text, html, javascript, css, xml:\nAddOutputFilterByType DEFLATE text\/plain\nAddOutputFilterByType DEFLATE text\/html\nAddOutputFilterByType DEFLATE text\/xml\nAddOutputFilterByType DEFLATE text\/css\nAddOutputFilterByType DEFLATE application\/xml\nAddOutputFilterByType DEFLATE application\/xhtml+xml\nAddOutputFilterByType DEFLATE application\/rss+xml\nAddOutputFilterByType DEFLATE application\/javascript\nAddOutputFilterByType DEFLATE application\/x-javascript<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"if-youre-not-using-apache-server\">If You\u2019re Not Using Apache Server<\/h3>\n\n\n\n<p>If you\u2019re not using an Apache server for web hosting, use the equivalents for the purpose of compression.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"compression-for-nginx-server\">Compression for NGINX Server<\/h4>\n\n\n\n<p>For the users stuck with NGINX server, fortunately ;), use this htaccess code in your configuration file in your web server.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gzip on;\ngzip_comp_level 2;\ngzip_http_version 1.0;\ngzip_proxied any;\ngzip_min_length 1100;\ngzip_buffers 16 8k;\ngzip_types text\/plain text\/html text\/css application\/x-javascript text\/xml application\/xml application\/xml+rss text\/javascript;\ngzip_disable \"MSIE &#91;1-6].(?!.*SV1)\";\ngzip_vary on;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"enabling-browser-caching\">Enabling Browser Caching<\/h3>\n\n\n\n<p>Enabling browser caching means the browsers will download\nsome resources in the local drive and when they are needed again, the browser\nuses those already stored files, consequently speeding up the process.<\/p>\n\n\n\n<p>The files to be stored for how long is dictated by\n.htaccess.<\/p>\n\n\n\n<p>Use these two codes methods to enable browser caching(recommended) <\/p>\n\n\n\n<h4 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"expires-headers\">EXPIRES HEADERS<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>#BEGIN EXPIRES HEADERS\n&lt;IfModule mod_expires.c&gt;\n# Enable expirations\nExpiresActive On\n# Default expiration: 1 hour after request\nExpiresDefault \"now plus 1 hour\"\n# CSS and JS expiration: 1 week after request\nExpiresByType text\/css \"now plus 1 week\"\nExpiresByType application\/javascript \"now plus 1 week\"\nExpiresByType application\/x-javascript \"now plus 1 week\"\n# Image files expiration: 1 month after request\nExpiresByType image\/bmp \"now plus 1 month\"\nExpiresByType image\/gif \"now plus 1 month\"\nExpiresByType image\/jpeg \"now plus 1 month\"\nExpiresByType image\/jp2 \"now plus 1 month\"\nExpiresByType image\/pipeg \"now plus 1 month\"\nExpiresByType image\/png \"now plus 1 month\"\nExpiresByType image\/svg+xml \"now plus 1 month\"\nExpiresByType image\/tiff \"now plus 1 month\"\nExpiresByType image\/vnd.microsoft.icon \"now plus 1 month\"\nExpiresByType image\/x-icon \"now plus 1 month\"\nExpiresByType image\/ico \"now plus 1 month\"\nExpiresByType image\/icon \"now plus 1 month\"\nExpiresByType text\/ico \"now plus 1 month\"\nExpiresByType application\/ico \"now plus 1 month\"\n# Webfonts\nExpiresByType font\/truetype \"access plus 1 month\"\nExpiresByType font\/opentype \"access plus 1 month\"\nExpiresByType application\/x-font-woff \"access plus 1 month\"\nExpiresByType image\/svg+xml \"access plus 1 month\"\nExpiresByType application\/vnd.ms-fontobject \"access plus 1 month\"\n&lt;\/IfModule&gt;\n#END EXPIRES HEADERS<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"cache-control\">Cache-Control<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code># BEGIN Cache-Control Headers\n&lt;ifModule mod_headers.c&gt;\n &lt;filesMatch \"\\.(ico|jpe?g|png|gif|swf)$\"&gt;\n Header set Cache-Control \"max-age=2592000, public\"\n &lt;\/filesMatch&gt;\n &lt;filesMatch \"\\.(css)$\"&gt;\n Header set Cache-Control \"max-age=604800, public\"\n &lt;\/filesMatch&gt;\n &lt;filesMatch \"\\.(js)$\"&gt;\n Header set Cache-Control \"max-age=216000, private\"\n &lt;\/filesMatch&gt;\n &lt;filesMatch \"\\.(x?html?|php)$\"&gt;\n Header set Cache-Control \"max-age=600, private, must-revalidate\"\n &lt;\/filesMatch&gt;\n&lt;\/ifModule&gt;\n# END Cache-Control Headers<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list is-style-checked\">\n<li>Enabling browser caching is guaranteed to speed up website loading.<\/li>\n\n\n\n<li>If you\u2019ve already enabled cache control by expiring the headers method and setting the time limit you don\u2019t need to do so, while enabling caching by cache control method in case you\u2019re putting both of them in use. It\u2019s not a problem to use both of them.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"lightspeed-server-cache\">LightSpeed Server Cache<\/h3>\n\n\n\n<p>Also, if possible, try to enable <a href=\"https:\/\/googiehost.com\/blog\/install-nginx-litespeed-direct-admin\/\" target=\"_blank\" rel=\"noreferrer noopener\">LightSpeed Server<\/a> Cache if you\u2019re using LightSpeed Server for running your website. <\/p>\n\n\n\n<p><strong>Use this code:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># ENABLE LITESPEED CACHE START\n&lt;IfModule LiteSpeed&gt;\nCacheEnable public\nRewriteEngine On\nRewriteCond %{REQUEST_METHOD} ^GET|HEAD$\nRewriteCond %{HTTP_HOST} ^sample.com|sample.net|sample.org &#91;NC]\nRewriteCond %{REQUEST_URI} !login|admin|register|post|cron\nRewriteCond %{QUERY_STRING} !nocache\nRewriteRule .* - &#91;E=Cache-Control:max-age=300]\n&lt;\/IfModule&gt;\n# ENABLE LITESPEED CACHE END<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"speeding-up-wordpress-by-enabling-keep-alive\">Speeding Up WordPress by Enabling Keep-Alive<\/h3>\n\n\n\n<p>Keep Alive is another trick that works; enabling it asks browsers to establish a TCP connection once and not multiple times. <\/p>\n\n\n\n<p>This kind of makes the browsers open a particular HTTP connection persistently for all files loading on your web page e.g. images, Javascript, CSS scripts, etc.<\/p>\n\n\n\n<p>Enable keep-alive is always recommended since there are no downsides to it. To enable keep alive, you can do it with HTTP header too. But we are going to it by .htaccess file here.<\/p>\n\n\n\n<p>Enabling Keep-Alive through .htaccess file<\/p>\n\n\n\n<p>Edit the .htaccess file, add this code in it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># START ENABLE KEEP ALIVE\n&lt;ifModule mod_headers.c&gt;\nHeader set Connection keep-alive\n&lt;\/ifModule&gt;\n# END ENABLE KEEP ALIVE<\/code><\/pre>\n\n\n\n<p><strong>Keep-alive<\/strong> is on by default on the NGINX server and it mostly comes auto-enabled<strong> on Apache servers.<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"speeding-up-website-by-disabling-image-hotlinking\">Speeding Up Website by Disabling Image Hotlinking<\/h3>\n\n\n\n<p>This is really something you need to disable if you are not using the image hotlinking feature because apart from reducing your website loading time this will save you from parasites. <\/p>\n\n\n\n<p>Many times, people can use the image on your website just by providing a link to it on their web pages. That way, every time the image is needed on any of the hot-linked pages, it is loaded from your server.<\/p>\n\n\n\n<p><strong>To disable image hotlinking use this code in your .htaccess file.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>________________________________________\nRewriteEngine on\nRewriteCond %{HTTP_REFERER} !^$\nRewriteCond %{HTTP_REFERER} !^http(s)?:\/\/(www\\.)?sample.com &#91;NC]\nRewriteCond %{HTTP_REFERER} !^http(s)?:\/\/(www\\.)?google.com &#91;NC]\nRewriteRule \\.(jpg|jpeg|png|gif)$ \u2013 &#91;NC,F,L]<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"enable-mod_pagespeed-for-faster-page-loading\">Enable mod_pagespeed for Faster Page Loading<\/h3>\n\n\n\n<p>Mod_pagespeed is an open-source module for optimizing files like HTML, Javascript, PNG, JPEG and CSS automatically. <\/p>\n\n\n\n<p>There are more than 40 filters that compress and resize images, concatenate and minify Javascript and CSS and a lot more. Mod_speed kind of trims redundant content and minimizes HTTP requests. <\/p>\n\n\n\n<p><strong>Include this code in your .htaccess file.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;IfModule pagespeed_module&gt;\nModPagespeed on\nModPagespeedEnableFilters rewrite_css,combine_css\nModPagespeedEnableFilters recompress_images\nModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp\nModPagespeedEnableFilters collapse_whitespace,remove_comments\n&lt;\/IfModule&gt;<\/code><\/pre>\n\n\n\n<p>After these guaranteed tricks to speed up your website on\nWordPress, let me tell you a bonus trick if you\u2019re not aware of it already,\nmight be useful sometime.<\/p>\n\n\n\n<div id=\"callout-block_4f4b93500e0ee8848f5c275b9c70bc31\" class=\"acf-callout has-label\" style=\"background-color: #e8f5e9; color: #1b5e20; border-color: #4caf50;\">\n        \n            <div class=\"acf-callout-label\">Tip<\/div>\n    \n    <div class=\"acf-callout-content\">\n        <div class=\"acf-innerblocks-container\">\n\n<p>After applying each .htaccess rule, test your site immediately using GTmetrix or Google PageSpeed Insights. This way you can isolate which rule causes issues if something breaks.<\/p>\n\n<\/div>\n    <\/div>\n\n    <\/div>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"url-canonicalization-redirection\">URL Canonicalization Redirection<\/h3>\n\n\n\n<p>In this case, you can redirect your&nbsp;<strong>non-www<\/strong>&nbsp;URL to&nbsp;the <strong>www&nbsp;<\/strong>URL. <\/p>\n\n\n\n<p>It becomes hard to determine which one of your correct URLs needs to be indexed by Google or other search engines.<\/p>\n\n\n\n<p>By adding a few lines in your .htaccess&nbsp;file you can easily resolve this issue which will optimize your site\u2019s speed.<\/p>\n\n\n\n<p>Also Read &#8211; <a href=\"https:\/\/googiehost.com\/blog\/free-hosting-server-for-java\/\">Free Hosting Server for Java<\/a><\/p>\n\n\n\n<p><strong>If you want to redirect www to a non-www URL:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>RewriteCond %{HTTP_HOST} ^www\\.example\\.com$\nRewriteRule ^\/?$ \"http\\:\\\/\\\/example\\.com\\\/\" &#91;R=301,L]<\/code><\/pre>\n\n\n\n<p><strong>If you want to redirect non-www to www URL:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>RewriteCond %{HTTP_HOST} !^www.example.com$ &#91;NC]\nRewriteRule ^(.*)$ http:\/\/www.example.com\/$1 &#91;L,R=301<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" class=\"wp-block-heading\" id=\"libwww-perl-access\">Libwww-Perl Access:<\/h3>\n\n\n\n<p>Check-in in case your server makes it possible for access from User-agent Libwww-Perl. <\/p>\n\n\n\n<p>Botnet scripts that automatically seek out vulnerabilities in your software are sometimes identified since User-Agent Libwww-Perl. <\/p>\n\n\n\n<p>By preventing access from Libwww-Perl it is possible to eliminate quite a few simpler problems. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>RewriteCond %{HTTP_USER_AGENT} libwww-perl.*\nRewriteRule .* \u2013 &#91;F,L]<\/code><\/pre>\n\n\n\n<p>Now you\u2019ve put all this effort into your website\u2019s speed optimization, find the page loading time baseline again. I\u2019m sure you\u2019d be surprised. <\/p>\n\n\n\n<div id=\"acf-accordion-block_dc71cc8ba7525da34b9bc1f7cf9187fd\" class=\"acf-accordion\">\n                <details class=\"acf-accordion-item\" open>\n                <summary class=\"acf-accordion-title\">\n                    What is a .htaccess file in WordPress?                <\/summary>\n                <div class=\"acf-accordion-content\">\n                    <p>The .htaccess file is an Apache server configuration file located in your WordPress root directory. It controls URL redirects, caching rules, compression, and security settings for your website.<\/p>\n                <\/div>\n            <\/details>\n                        <details class=\"acf-accordion-item\">\n                <summary class=\"acf-accordion-title\">\n                    Can .htaccess changes break my website?                <\/summary>\n                <div class=\"acf-accordion-content\">\n                    <p>Yes, a syntax error in .htaccess can cause a 500 Internal Server Error. Always keep a backup copy and test changes one at a time so you can quickly revert if needed.<\/p>\n                <\/div>\n            <\/details>\n                        <details class=\"acf-accordion-item\">\n                <summary class=\"acf-accordion-title\">\n                    Does .htaccess work on Nginx servers?                <\/summary>\n                <div class=\"acf-accordion-content\">\n                    <p>No, .htaccess is specific to Apache servers. Nginx uses its own configuration files (nginx.conf). If you are on Nginx, you need to add equivalent directives to your server block configuration.<\/p>\n                <\/div>\n            <\/details>\n                        <details class=\"acf-accordion-item\">\n                <summary class=\"acf-accordion-title\">\n                    Should I use a caching plugin instead of .htaccess?                <\/summary>\n                <div class=\"acf-accordion-content\">\n                    <p>Both work well together. Caching plugins like LiteSpeed Cache or WP Rocket handle page caching, while .htaccess rules manage browser caching, compression, and server-level optimizations.<\/p>\n                <\/div>\n            <\/details>\n                        <details class=\"acf-accordion-item\">\n                <summary class=\"acf-accordion-title\">\n                    How do I check if GZIP compression is enabled?                <\/summary>\n                <div class=\"acf-accordion-content\">\n                    <p>Use online tools like GIDNetwork&#8217;s GZIP test or check the Network tab in your browser&#8217;s developer tools. Look for Content-Encoding: gzip in the response headers.<\/p>\n                <\/div>\n            <\/details>\n            <\/div>\n\n    <script type=\"application\/ld+json\">\n        {\"@context\":\"https:\/\/schema.org\",\"@type\":\"FAQPage\",\"mainEntity\":[{\"@type\":\"Question\",\"name\":\"What is a .htaccess file in WordPress?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"The .htaccess file is an Apache server configuration file located in your WordPress root directory. It controls URL redirects, caching rules, compression, and security settings for your website.\"}},{\"@type\":\"Question\",\"name\":\"Can .htaccess changes break my website?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Yes, a syntax error in .htaccess can cause a 500 Internal Server Error. Always keep a backup copy and test changes one at a time so you can quickly revert if needed.\"}},{\"@type\":\"Question\",\"name\":\"Does .htaccess work on Nginx servers?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"No, .htaccess is specific to Apache servers. Nginx uses its own configuration files (nginx.conf). If you are on Nginx, you need to add equivalent directives to your server block configuration.\"}},{\"@type\":\"Question\",\"name\":\"Should I use a caching plugin instead of .htaccess?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Both work well together. Caching plugins like LiteSpeed Cache or WP Rocket handle page caching, while .htaccess rules manage browser caching, compression, and server-level optimizations.\"}},{\"@type\":\"Question\",\"name\":\"How do I check if GZIP compression is enabled?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Use online tools like GIDNetwork's GZIP test or check the Network tab in your browser's developer tools. Look for Content-Encoding: gzip in the response headers.\"}}]}    <\/script>\n\n\n\n<div class=\"acf-cta-block\" style=\"background-color: #0d47a1; color: #ffffff\">\n    <div class=\"acf-cta-content\">\n                                                <h2 class=\"acf-cta-heading\" class=\"acf-cta-heading\" id=\"speed-up-your-wordpress-site-today\">Speed Up Your WordPress Site Today<\/h2>\n            \n                            <div class=\"acf-cta-description\">\n                    <p>Get LiteSpeed-powered hosting with built-in caching for blazing-fast WordPress performance.<\/p>                <\/div>\n            \n                            <a href=\"https:\/\/googiehost.com\/blog\/best-litespeed-hosting\/\" class=\"acf-cta-button primary\">\n                    Explore LiteSpeed Hosting                <\/a>\n                        <\/div>\n<\/div>\n\n\n","protected":false},"excerpt":{"rendered":"<p>After you\u2019re done putting on good quality content on your website and have made it eye-catching and attractive, you have&#8230;<\/p>\n","protected":false},"author":1,"featured_media":37678,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[7,5,6],"tags":[10,9],"class_list":["post-20","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","category-blogging","category-seo","tag-enabling-gzip-using-htaccess","tag-htacess-commands"],"acf":[],"_links":{"self":[{"href":"https:\/\/googiehost.com\/blog\/wp-json\/wp\/v2\/posts\/20","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/googiehost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/googiehost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/googiehost.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/googiehost.com\/blog\/wp-json\/wp\/v2\/comments?post=20"}],"version-history":[{"count":0,"href":"https:\/\/googiehost.com\/blog\/wp-json\/wp\/v2\/posts\/20\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/googiehost.com\/blog\/wp-json\/wp\/v2\/media\/37678"}],"wp:attachment":[{"href":"https:\/\/googiehost.com\/blog\/wp-json\/wp\/v2\/media?parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/googiehost.com\/blog\/wp-json\/wp\/v2\/categories?post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/googiehost.com\/blog\/wp-json\/wp\/v2\/tags?post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}