{"id":2975,"date":"2020-01-27T15:17:53","date_gmt":"2020-01-27T14:17:53","guid":{"rendered":"https:\/\/www.combell.com\/en\/help\/?post_type=ht_kb&#038;p=2975"},"modified":"2024-06-10T16:09:19","modified_gmt":"2024-06-10T14:09:19","slug":"optimize-wordpress","status":"publish","type":"ht_kb","link":"https:\/\/www.combell.com\/en\/help\/kb\/optimize-wordpress\/","title":{"rendered":"Optimize WordPress"},"content":{"rendered":"\n<p>Optimize your WordPress website to get the most out of your hosting package. With some adjustments, this popular CMS is also suitable for large websites.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-ht-block-toc  is-style-outline htoc htoc--position-wide toc-list-style-plain\" data-htoc-state=\"expanded\"><span class=\"htoc__title\"><span class=\"ht_toc_title\">Table of Contents<\/span><span class=\"htoc__toggle\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"16\" height=\"16\"><g fill=\"#444\"><path d=\"M15 7H1c-.6 0-1 .4-1 1s.4 1 1 1h14c.6 0 1-.4 1-1s-.4-1-1-1z\"><\/path><path d=\"M15 1H1c-.6 0-1 .4-1 1s.4 1 1 1h14c.6 0 1-.4 1-1s-.4-1-1-1zM15 13H1c-.6 0-1 .4-1 1s.4 1 1 1h14c.6 0 1-.4 1-1s-.4-1-1-1z\"><\/path><\/g><\/svg><\/span><\/span><div class=\"htoc__itemswrap\"><ul class=\"ht_toc_list\"><li class=\"\"><a href=\"#caching\">Activate caching and Boost<\/a><\/li><li class=\"\"><a href=\"#plugins\">WordPress settings and recommended plugins<\/a><\/li><li class=\"\"><a href=\"#htaccess\">Optimize the .htaccess file<\/a><\/li><li class=\"\"><a href=\"#wpconfig\">Optimize the wp-config.php file<\/a><\/li><\/ul><\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"caching\">Activate caching and Boost<\/h2>\n\n\n\n<p>Caching is the way to make WordPress faster. Caching frees up extra memory to your RAM to speed up your web hosting.<\/p>\n\n\n\n<p>Your website will no longer need to retrieve certain data for each visitor from the database. Instead, it immediately retrieves that data from RAM, which drastically reduces the loading time.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.combell.com\/en\/help\/kb\/activate-caching-on-your-webhosting\/\">Read how to activate caching on your web hosting<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.combell.com\/en\/help\/kb\/how-to-implement-redis-in-wordpress\/\">Add <strong>Redis<\/strong> caching to your WordPress website<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.combell.com\/en\/help\/kb\/how-to-implement-ramdisk-in-wordpress\/\">Add <strong>Ramdisk<\/strong> caching to your WordPress website<\/a><\/p>\n\n\n\n<p><strong>Recommended<\/strong>: <a href=\"https:\/\/www.combell.com\/en\/help\/kb\/make-your-hosting-faster-with-boost\/\">Make your website faster with <strong>Boost<\/strong><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"plugins\">WordPress settings and recommended plugins<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"htoc-disable-pingbacks\">Disable pingbacks<\/h3>\n\n\n\n<p>Pingbacks are enabled by default on WordPress. They make it so other websites are notified when you link to them. But that creates many unnecessary queries.<br>Therefore, we recommend disabling pingbacks via the &#8220;settings&#8221; in WordPress (see image).<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.combell.com\/en\/help\/wp-content\/uploads\/pingback.png\" alt=\"\" class=\"wp-image-10421\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"htoc-compress-images-with-wp-smush-it\">Compress images with WP Smush.it<\/h3>\n\n\n\n<p>WP Smush.it is perfect if you have a lot of images on your website that are not size optimized. WP Smush.it makes the images smaller so that they load faster.<\/p>\n\n\n\n<div class=\"wp-block-ht-blocks-toggle wp-block-hb-toggle\"><div class=\"wp-block-hb-toggle__title\"><span>Follow these steps to install the plugin<\/span><\/div><div class=\"wp-block-hb-toggle__content\"><div class=\"wp-block-hb-toggle__contentwrap\">1. Log in on your WordPress admin area.<br>2. Via the menu to your left, go to \u201cPlugins\u201d &gt; \u201cAdd new\u201d.<br>3. Search for the plugin in the search bar and click on \u201cInstall now\u201d when you find it.<br>4. Installed the plugin? Go to \u201cPlugins\u201d &gt; \u201cInstalled plugins\u201d to activate the new plugin. Only now the plugin will start working.<\/div><\/div><\/div>\n\n\n\n<p>An alternative is the automatic compression of WordPress done from &#8220;Settings&#8221; &gt; &#8220;Media&#8221;.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"htoc-optimize-your-database-with-rvg-optimize-database\">Optimize your database with RVG-Optimize Database<\/h3>\n\n\n\n<p>RVG-Optimize Database optimizes the tables in your database(s). You also clean up the clutter in your database(s). Easily remove revisions from posts, pages etc.<\/p>\n\n\n\n<div class=\"wp-block-ht-blocks-toggle wp-block-hb-toggle\"><div class=\"wp-block-hb-toggle__title\"><span>Follow these steps to install the plugin<\/span><\/div><div class=\"wp-block-hb-toggle__content\"><div class=\"wp-block-hb-toggle__contentwrap\">1. Log in on your WordPress admin area.<br>2. Via the menu to your left, go to \u201cPlugins\u201d &gt; \u201cAdd new\u201d.<br>3. Search for the plugin in the search bar and click on \u201cInstall now\u201d when you find it.<br>4. Installed the plugin? Go to \u201cPlugins\u201d &gt; \u201cInstalled plugins\u201d to activate the new plugin. Only now the plugin will start working.<\/div><\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"htoc-activate-http-2-server-push\">Activate HTTP\/2 server push<\/h3>\n\n\n\n<p>Does your website work via HTTPS (because you have an SSL certificate)? Then we recommend to also <a href=\"https:\/\/www.combell.com\/en\/help\/kb\/activate-http-2\/\">activate HTTP\/2<\/a>.<br>With HTTP\/2, multiple files can be sent via multiplexing over a single connection at the same time, resulting in a faster website.<\/p>\n\n\n\n<p>An extra step is to activate HTTP\/2 server push. This is a technique that will further reduce the loading time of your website.<br>You will need to install the <a href=\"https:\/\/wordpress.org\/plugins\/http2-server-push\/\" target=\"_blank\" rel=\"noopener\">HTTP\/2 server push<\/a> plugin. It ensures that all scripts and files that use the &#8220;enqueue mechanism&#8221; are sent to the browsers via preloading.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"htoc-optimize-for-mobile-devices-with-the-amp-plugin\">Optimize for mobile devices with the AMP plugin<\/h3>\n\n\n\n<p>To optimize your website for mobile, you should use Google&#8217;s AMP project. AMP stands for Accelerated Mobile Pages. By removing a lot of &#8220;clutter&#8221; from your website (eg certain design elements, scripts &#8230;), your website will work a lot faster.<\/p>\n\n\n\n<p>Install the AMP plugin on your WordPress website. https:\/\/nl.wordpress.org\/plugins\/amp\/<\/p>\n\n\n\n<div class=\"wp-block-ht-blocks-toggle wp-block-hb-toggle\"><div class=\"wp-block-hb-toggle__title\"><span>Follow these steps to install the plugin<\/span><\/div><div class=\"wp-block-hb-toggle__content\"><div class=\"wp-block-hb-toggle__contentwrap\">1. Log in on your WordPress admin area.<br>2. Via the menu to your left, go to \u201cPlugins\u201d &gt; \u201cAdd new\u201d.<br>3. Search for the plugin in the search bar and click on \u201cInstall now\u201d when you find it.<br>4. Installed the plugin? Go to \u201cPlugins\u201d &gt; \u201cInstalled plugins\u201d to activate the new plugin. Only now the plugin will start working.<\/div><\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"htaccess\">Optimize the .htaccess file<\/h2>\n\n\n\n<p>With a few adjustments to your .htaccess file, you optimize WordPress for a large number of visitors. An overview of recommended adjustments!<\/p>\n\n\n\n<p class=\"wp-block-ht-blocks-messages wp-block-hb-message wp-block-hb-message--withicon is-style-info\"><strong>Tip: these adjustments are best done via SSH<br><\/strong>To start, activate SSH and make an SSH connection to your computer, for example via SSH keys. If you still want to edit the .htaccess file via FTP, make sure the FTP client shows hidden files, otherwise, you will not see the .htaccess file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"htoc-activate-gzip-compression\">Activate GZIP-compression<\/h3>\n\n\n\n<p>Compress various files on your website. This ensures less bandwidth consumption and, above all, a shorter loading time.<\/p>\n\n\n\n<ol>\n<li><a href=\"https:\/\/www.combell.com\/en\/help\/kb\/how-can-i-enable-gzip-compression\/\">Activate GZIP-compression vie the control panel<\/a><\/li>\n\n\n\n<li>Add the code below to the .htaccess file<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;IfModule mod_deflate.c&gt;\n&lt;FilesMatch \"\\.(html|php|txt|xml|js|css)$\"&gt;\nSetOutputFilter DEFLATE\n&lt;\/FilesMatch&gt;\n&lt;\/IfModule&gt;<\/code><\/pre>\n\n\n\n<p>Alternative: add Deflate Compression by adding the code below to your .htacces file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># START DEFLATE COMPRESSION \n\t\n\tAddOutputFilterByType DEFLATE \"application\/atom+xml\" \\ \n\t\"application\/javascript\" \\ \n\t\"application\/json\" \\ \n\t\"application\/ld+json\" \\ \n\t\"application\/manifest+json\" \\ \n\t\"application\/rdf+xml\" \\ \n\t\"application\/rss+xml\" \\ \n\t\"application\/schema+json\" \\ \n\t\"application\/vnd.geo+json\" \\ \n\t\"application\/vnd.ms-fontobject\" \\ \n\t\"application\/x-font\" \\ \n\t\"application\/x-font-opentype\" \\ \n\t\"application\/x-font-otf\" \\ \n\t\"application\/x-font-truetype\" \\ \n\t\"application\/x-font-ttf\" \\ \n\t\"application\/x-javascript\" \\ \n\t\"application\/x-web-app-manifest+json\" \\ \n\t\"application\/xhtml+xml\" \\ \n\t\"application\/xml\" \\ \n\t\"font\/eot\" \\ \n\t\"font\/otf\" \\ \n\t\"font\/ttf\" \\ \n\t\"font\/opentype\" \\ \n\t\"image\/bmp\" \\ \n\t\"image\/svg+xml\" \\ \n\t\"image\/vnd.microsoft.icon\" \\ \n\t\"image\/x-icon\" \\ \n\t\"text\/cache-manifest\" \\ \n\t\"text\/css\" \\ \n\t\"text\/html\" \\ \n\t\"text\/javascript\" \\ \n\t\"text\/plain\" \\ \n\t\"text\/vcard\" \\ \n\t\"text\/vnd.rim.location.xloc\" \\ \n\t\"text\/vtt\" \\ \n\t\"text\/x-component\" \\ \n\t\"text\/x-cross-domain-policy\" \\ \n\t\"text\/xml\" \n\n# DEFLATE COMPRESSION<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"htoc-activate-expire-headers\">Activate Expire headers<\/h3>\n\n\n\n<p>By enforcing expire headers you ensure the caching of certain file types. This ensures that they are always in the cache, making them load faster.<br>Add the following code to your .htaccess file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\t# BEGIN Expire headers\n\n  ExpiresActive On\n \n  # Images\n  ExpiresByType image\/jpeg \"access plus 1 year\"\n  ExpiresByType image\/gif \"access plus 1 year\"\n  ExpiresByType image\/png \"access plus 1 year\"\n  ExpiresByType image\/webp \"access plus 1 year\"\n  ExpiresByType image\/svg+xml \"access plus 1 year\"\n  ExpiresByType image\/x-icon \"access plus 1 year\"\n \n  # Video\n  ExpiresByType video\/mp4 \"access plus 1 year\"\n  ExpiresByType video\/mpeg \"access plus 1 year\"\n \n  # CSS, JavaScript\n  ExpiresByType text\/css \"access plus 1 month\"\n  ExpiresByType text\/javascript \"access plus 1 month\"\n  ExpiresByType application\/javascript \"access plus 1 month\"\n \n  # Others\n  ExpiresByType application\/pdf \"access plus 1 month\"\n  ExpiresByType application\/x-shockwave-flash \"access plus 1 month\"\n\n# END Expire headers\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"htoc-add-cache-control-headers\">Add cache control headers<\/h3>\n\n\n\n<p>Cache control headers define files that can be cached by the browser.<br>Add the code below to your .htaccess file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># BEGIN Cache-Control Headers\n\n&lt;filesMatch \"\\.(ico|jpeg|jpg|png|gif|swf|pdf|svg|js|flv)$\"&gt;\nHeader set Cache-Control \"max-age=84600, public\"\n\n\n# END Cache-Control Headers<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"htoc-disable-entity-tags\">Disable entity tags<\/h3>\n\n\n\n<p>Entity tags is a mechanism that checks whether the files in the browser cache still match the files on the server. By switching this off, a faster loading time can be achieved. Although the result differs from website to website.<\/p>\n\n\n\n<p>Add the following code to your .htacess file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\tHeader unset ETag\n\tFileETag None\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"htoc-neutralize-image-hotlinking\">Neutralize image hotlinking<\/h3>\n\n\n\n<p>Image hotlinking occurs when another website uses your images (they link directly to your image). That creates extra load on your hosting. You can prevent this in some cases by adding the following lines to your .htaccess file.<\/p>\n\n\n\n<p>Don&#8217;t forget to change the domain name to your own domain name.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">RewriteEngine on\nRewriteCond %{HTTP_REFERER} !^http(s)?:\/\/(www\\.)?yourdomainname.com [NC]\nRewriteCond %{HTTP_REFERER} !^http(s)?:\/\/(www\\.)?google.com [NC]\nRewriteRule \\.(jpg|jpeg|png|gif)$ - [NC,F,L]<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"htoc-stop-landing-page-redirects\">Stop landing page redirects<\/h3>\n\n\n\n<p>When using GTMetrix, you sometimes get the following message:<br>&#8220;Avoid landing page redirects for the following chain of URLs&#8221;.<br>This occurs when you have an SSL certificate installed but do not have a direct redirect from HTTP to HTTPS.<\/p>\n\n\n\n<p>To prevent this, add the following lines to your .htaccess file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\t#redirect non-www to www\n\tRewriteEngine On\n\tRewriteCond %{HTTP_HOST} !^www\\.\n\tRewriteRule ^(.*)$ https:\/\/www.%{HTTP_HOST}\/$1 [R=301,L]\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"wpconfig\">Optimize the wp-config.php file<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"htoc-limit-the-number-of-revisions-of-wp-config-php\">Limit the number of revisions of wp-config.php<\/h3>\n\n\n\n<p>There is no single button in WordPress to limit the number of revisions stored in your database. A large number of revisions will mean your website will go slower. Therefore, setting a limit is recommended.<\/p>\n\n\n\n<p>Add the following code to your wp-config.php file to limit the number of stored revisions to 3:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">define( 'WP_POST_REVISIONS', 3 );<\/pre>\n\n\n\n<p>To disable it completely, add the following code.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">define( 'WP_POST_REVISIONS', false );<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"htoc-stop-wp-cron\">Stop WP-cron<\/h3>\n\n\n\n<p>WP-cron is allso called &#8220;a poor man&#8217;s cron&#8221;. It ensures that every time someone visits your website, a check is performed on whether there are any pending actions within WordPress. If that is the case, they will be executed immediately.<\/p>\n\n\n\n<p>Disable this by adding the following code to your wp-config.php file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">define('DISABLE_WP_CRON', true);<\/pre>\n\n\n\n<p>If you still want to perform specific cron tasks automatically, you can do this via the crontab.<br><a href=\"https:\/\/www.combell.com\/en\/help\/kb\/programming-recurring-tasks-with-cronjobs\/\">Create a cron job<\/a> via the control panel with the following code:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">*\/30 * * * * curl -sLo \/dev\/null https:\/\/domain.extension\/wp-cron.php?doing_wp_cron<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Optimize your WordPress website to get the most out of your hosting package. With some adjustments, this popular CMS is also suitable for large websites. Activate caching and Boost Caching is the way to make WordPress faster. Caching frees up extra memory to your RAM to speed up your web&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[47,48,4],"ht-kb-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb\/2975"}],"collection":[{"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/comments?post=2975"}],"version-history":[{"count":15,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb\/2975\/revisions"}],"predecessor-version":[{"id":4345,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb\/2975\/revisions\/4345"}],"wp:attachment":[{"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/media?parent=2975"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb-category?post=2975"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.combell.com\/en\/help\/wp-json\/wp\/v2\/ht-kb-tag?post=2975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}