Posted on Leave a comment

WordPress cache leverage no plugin browser loading faster .htaccess

Would you like to enhance the performance of your WordPress website with an easy method? You can achieve this by following these straightforward steps. Caching is a technique that boosts your website’s speed. It involves storing cached files in the user’s browser, eliminating the need for repeated downloads. In essence, this leads to quicker loading times as data is already stored in the user’s browser, thus accelerating your WordPress site. Let’s enhance the speed and optimization of your WordPress website immediately.

Step 1: Evaluate Your Website’s Loading Time

Initially, it’s crucial to obtain your website’s speed result as a percentage. This step holds significant importance since, prior to proceeding with any further steps, it allows you to gauge your website’s speed and overall performance. To achieve this, assess your site’s speed by using Google PageSpeed Insights, which will provide you with your current score.

Step 2: Access Your .htaccess File

Locate the .htaccess file in the root directory of your website. If you’re not already in the root directory, navigate to it. In case you can’t find the .htaccess file, follow these steps: Go to the top right corner, click on “Settings,” then enable the option to display hidden files by checking ‘Show all hidden files.’ With this setting enabled, you should be able to access the .htaccess file. Click on it to open and make necessary edits.

Step 3: Modify the .htaccess File

You can copy the provided codes below and paste them into your .htaccess file. To establish expiration times for resources like images, HTML, JavaScript, and CSS files, a minor adjustment to your file is necessary. Choose values that align with your site’s needs; typically, a duration of 1 month suffices.

#EDITMODIFY
#Customize expires caching start - adjust the period according to your needs
<IfModule mod_expires.c>
  FileETag MTime Size
  AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
  ExpiresActive On
  ExpiresByType text/html "access 600 seconds"
  ExpiresByType application/xhtml+xml "access 600 seconds"
  ExpiresByType text/css "access 1 month"
  ExpiresByType text/javascript "access 1 month"
  ExpiresByType text/x-javascript "access 1 month"
  ExpiresByType application/javascript "access 1 month"
  ExpiresByType application/x-javascript "access 1 month"
  ExpiresByType application/x-shockwave-flash "access 1 month"
  ExpiresByType application/pdf "access 1 month"
  ExpiresByType image/x-icon "access 1 year"
  ExpiresByType image/jpg "access 1 year"  
  ExpiresByType image/jpeg "access 1 year"
  ExpiresByType image/png "access 1 year"
  ExpiresByType image/gif "access 1 year"
  ExpiresDefault "access 1 month"
</IfModule>
#Expires caching end

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

# Disable ETags
<IfModule mod_headers.c>
	Header unset ETag
</IfModule>

Step 4: Reassess Your Website’s Speed

Conduct another evaluation of your website’s performance by using Google PageSpeed Insights to observe your updated score.

Step 4: Reevaluate Your Website’s Speed

Perform a retest of your website’s speed using Google PageSpeed Insights in order to observe and assess your newly updated score.

References for Further Enhancement: Take into account the tutorials provided below to enhance your website’s speed and optimization more effectively. In the aforementioned steps, we have highlighted various methods to ensure effective browser caching and the reuse of downloaded content.

Leave a Reply