Search code examples
php.htaccessopencartopencart-3

How to use .htaccess to speed up your site


htaccess is a special configuration file in which you should be able to dig up in the root of your server directory.

How can I speed-up my Website using htaccess

My Website Score:

  • Desktop : 61

  • Mobile : 42

How can I improve my website page speed?


Solution

  • I have completely tested it on my website.

    You can add the following code in your .htaccess file in the route Directory.

    # Compress Text, HTML, JavaScript, CSS, and XML
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    
    # Remove Browser Bugs
    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