Categories
Wordpress

How to remove WordPress version parameter from JS and CSS files

Categories
Wordpress

WP ROCKET: Boost WordPress Web Performance

 WP ROCKET?

WP Rocket is a speed optimization plugin for WordPress helping you implement a variety of speed-boosting features to your WordPress site. This is the most powerful cache plugin by WordPress Experts. No coding knowledge is required.

Easily deploy features like,

  • GZIP Compression
  • Enable HTML Minification 
  • CSS Minification
  • JS Minification 
  • LazyLoad
  • Cloudflare Compatibility
  • Google Fonts Optimization
  • Mobile Detection

Page caching is activated by default when you activate WP Rocket. If Varnish service is enabled on your server at Cloudways (it is by default), then go to the Varnish tab in WP Rocket and check the box to Enable the Varnish caching auto-purge.

WP Rocket vs W3 Total Cache

WP Rocket is a premium plugin but is easier to configure and more reliable than W3 Total Cache (it won’t break your site). 

W3 Total Cache does not support the following,

  • Database Cleanup
  • Lazy Loading
  • Google Analytics
  • Preloading

You would need to install 2-3 extra plugins if you wanted to use these features with W3 Total Cache whether as WP Rocket supports the above features by default.

WP Rocket vs WP Super Cache

WP Super Cache is a free caching solution available for WordPress. Its caching mechanism is fairly easy to understand. The plugin basically generates static HTML files from your dynamic WordPress blog and caches it instead of the WordPress PHP scripts.

If you’re looking for the highest-performing caching plugin, we do recommend WP Rocket.

Categories
Wordpress

How to Speed up WordPress Using .htaccess

In this post we’re going to cover how to speed up WordPress using .htaccess.

You can copy the below code and paste it into your htaccess file. Once you’ve done that, save your htaccess file and enjoy faster loading speeds.

Adding expires Header

We have given the age of one month to all CSS, javascript and shockwave files. As for icons, they have a one year age, and other static resources have a one month age. For these rules that we have specified to work, we need to have enabled the mod_expires module. By default, most servers have it enabled. Remember, set expiry dates for a year. It’s not recommended you set less than a month or more than a year.

# TN - START EXPIRES CACHING #
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresDefault "access 1 month"
</IfModule>
# TN - END EXPIRES CACHING #

Adding cache control headers

Here, you can set a timeline, but it won’t be necessary as you’ve already set expiry dates for the cached resources.

# TN - BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "private"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "private, must-revalidate"
</filesMatch>
</ifModule>
# TN - END Cache-Control Headers

Disabling the Etag header

The technology used to make the Etag header is very slow hence by disabling it, we are doing our loading speeds big favor. Here we are also using the keep-alive connection. It keeps the current connection alive since opening a new connection takes a longer time.

#Disable Etags
<IfModule mod_headers.c>
   Header unset Etag
   Header set Connection keep-alive
</IfModule>
FileETag None

Deflating compression headers

If we deflate our components, they become smaller hence, loading faster. This method might not work for your case if your server does not have mod_deflate or mod_gzip installed as part of Apache. Ensure you add it below the contents of the htaccess file.Deflating compression headers

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml
  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>