The Best Way to Speed Up Your Website by.htaccess

No need to compress JS images and CSS with code. All websites are compressed automatically when you just add this code to your htacess file.

# COMBINE CSS, COMPRESS IMAGES, REMOVE HTML WHITE SPACE AND COMMENTS
<IfModule pagespeed_module>
ModPagespeed on
ModPagespeedEnableFilters rewrite_css,combine_css
ModPagespeedEnableFilters recompress_images
ModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp
ModPagespeedEnableFilters collapse_whitespace,remove_comments
</IfModule>
# TN – ENABLE MOD PAGESPEED END

#Disallow custom css and js
ModPagespeedDisallow "*/filename.js"




##### Optimize default expiration time - BEGIN
<IfModule mod_expires.c>
    ## Enable expiration control
    ExpiresActive On

    ## CSS and JS expiration: 1 week after request
    ExpiresByType text/css "now plus 1 week"
    ExpiresByType application/javascript "now plus 1 week"
    ExpiresByType application/x-javascript "now plus 1 week"

    ## Image files expiration: 1 month after request
    ExpiresByType image/bmp "now plus 1 month"
    ExpiresByType image/gif "now plus 1 month"
    ExpiresByType image/jpeg "now plus 1 month"
    ExpiresByType image/jp2 "now plus 1 month"
    ExpiresByType image/pipeg "now plus 1 month"
    ExpiresByType image/png "now plus 1 month"
    ExpiresByType image/svg+xml "now plus 1 month"
    ExpiresByType image/tiff "now plus 1 month"
    ExpiresByType image/x-icon "now plus 1 month"
    ExpiresByType image/ico "now plus 1 month"
    ExpiresByType image/icon "now plus 1 month"
    ExpiresByType text/ico "now plus 1 month"
    ExpiresByType application/ico "now plus 1 month"
    ExpiresByType image/vnd.wap.wbmp "now plus 1 month"

    ## Font files expiration: 1 week after request
    ExpiresByType application/x-font-ttf "now plus 1 week"
    ExpiresByType application/x-font-opentype "now plus 1 week"
    ExpiresByType application/x-font-woff "now plus 1 week"
    ExpiresByType font/woff2 "now plus 1 week"
    ExpiresByType image/svg+xml "now plus 1 week"

    ## Audio files expiration: 1 month after request
    ExpiresByType audio/ogg "now plus 1 month"
    ExpiresByType application/ogg "now plus 1 month"
    ExpiresByType audio/basic "now plus 1 month"
    ExpiresByType audio/mid "now plus 1 month"
    ExpiresByType audio/midi "now plus 1 month"
    ExpiresByType audio/mpeg "now plus 1 month"
    ExpiresByType audio/mp3 "now plus 1 month"
    ExpiresByType audio/x-aiff "now plus 1 month"
    ExpiresByType audio/x-mpegurl "now plus 1 month"
    ExpiresByType audio/x-pn-realaudio "now plus 1 month"
    ExpiresByType audio/x-wav "now plus 1 month"

    ## Movie files expiration: 1 month after request
    ExpiresByType application/x-shockwave-flash "now plus 1 month"
    ExpiresByType x-world/x-vrml "now plus 1 month"
    ExpiresByType video/x-msvideo "now plus 1 month"
    ExpiresByType video/mpeg "now plus 1 month"
    ExpiresByType video/mp4 "now plus 1 month"
    ExpiresByType video/quicktime "now plus 1 month"
    ExpiresByType video/x-la-asf "now plus 1 month"
    ExpiresByType video/x-ms-asf "now plus 1 month"
</IfModule> 

##### 1 Month for most static resources
<filesMatch ".(css|jpg|jpeg|png|gif|js|ico)$">
    Header set Cache-Control "max-age=31536000, public"
</filesMatch>

##### Enable gzip compression for resources
<ifModule mod_gzip.c>
    mod_gzip_on Yes
    mod_gzip_dechunk Yes
    mod_gzip_item_include file .(html?|txt|css|js|php)$
    mod_gzip_item_include handler ^cgi-script$
    mod_gzip_item_include mime ^text/.*
    mod_gzip_item_include mime ^application/x-javascript.*
    mod_gzip_item_exclude mime ^image/.*
    mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

##### Set Header Vary: Accept-Encoding
<IfModule mod_headers.c>
    <FilesMatch ".(js|css|xml|gz|html)$">
        Header append Vary: Accept-Encoding
    </FilesMatch>
</IfModule>

Related Articles

No need to compress JS images and CSS with code. All websites are...

Read More
  • Serendi Pity Housegoa

    ...

    Read More
  • Svelte

    ...

    Read More
  • Art For concern

    ...

    Read More
  • Concern India Foundation

    ...

    Read More
  • Medtalks

    ...

    Read More
  • Pickahome

    ...

    Read More
  • Mychefbook

    ...

    Read More
  • How to Get Started with Arduino

    You Will Need

    Read More
  • Sync EC2 Instance With S3 Bucket and S3 to ec2

    Create IAM User with full Access s3

    Switcharys (HTML Toggle Switch Button) are part of the modern UX and are...

    Read More
  • 360 Degree View video of the belaire

    DLF Belaire is one the finest properties on DLF phase 5 . Mindmyweb worked with pickahome to create...

    Read More
  • Balloon design for pickahome

    This is a virtually edited video we made just for fun. Designed with a Read More

  • Indian Guys Try girly drinks

    Funny alcohol review video created by coctail crew...

    Read More
  • Joininghands Donation Poster

    Quick promotional poster for joining hands India Read More

  • Shooting DLF Pinnacle on iphone 6

    I was just passing DLF pinnacle gurgaon when I decided to shoot a very unique view of this lovely...

    Read More
  • Arial Panorama For MGF Villas | pickahome

    A look at some stunning Arial time laps photos of Read More

  • Arial Panorama for DLF phase 2 | Real Estate

    DLF phase 2 is a residential...

    Read More
  • Arial Panoramic images for DLF phase 5

    Arial Panoramics were one of the biggest challenges for the Read More

  • How to install Pokémon go on iphone from India / Singapore / Japan

    The world is going Pokémon go crazy and there is a good reason for that. ITs a revolutionary game...

    Read More
  • How to display Indian rupees symbol in modern browser

    As a web developer when I see errors on the web it hits me immediately. I am seeing large...

    Read More
  • Deference Between @media OR @media screen OR @media only screen

    How to write a media query to target specific...

    Read More

  • 5 experiential tips for aspiring entrepreneurs

    Respect is important

     

    Over the years I have met a lot of...

    Read More
  • Life Lesson's – Does your startup have the right gear?

    Life Lesson’s – Does your startup have the right gear?

    I remember...

    Read More
  • 5 startup lessons from counter strike

    I have been a gamer for as long as I remember – I always wanted to be a game designer as a...

    Read More
  • -->