Browser Caching

Leveraging browser caching allows you to specify how long your visitors’ browsers should store cached copies of your images, CSS, JavaScript, and Flash files. When these resources are updated, your server will notify the browser, which will then replace the cached content with the new version. To enable browser caching, add the following lines to your `.htaccess` file:

<!-- LEVERAGE BROWSER CACHING -->
    ExpiresActive On
    ExpiresByType image/jpg "access 1 year"
    ExpiresByType image/jpeg "access 1 year"
    ExpiresByType image/gif "access 1 year"
    ExpiresByType image/png "access 1 year"
    ExpiresByType text/css "access 1 month"
    ExpiresByType application/pdf "access 1 month"
    ExpiresByType application/x-javascript "access 1 month"
    ExpiresByType application/javascript "access 1 month"
    ExpiresByType application/x-shockwave-flash "access 1 month"
    ExpiresByType image/x-icon "access 1 year"
    ExpiresDefault "access 2 days"
    <!-- LEVERAGE BROWSER CACHING -->

HTML

CSS & JS Minification

Minifying your CSS and JavaScript files is highly recommended to reduce their file sizes and enhance loading speeds in the browser. Numerous online tools are available for this purpose. While we suggest the tools listed below, you are welcome to use any other tools of your choice.

NoteIf you are using Gulp.js provided in the Crafto package then it will minify CSS and JS files and hence you do not need to use the above tools.

Image Compression

Often, we upload large images to our websites without optimizing them, which can significantly slow down page load times. Large images take longer to download, potentially causing visitors to leave if your site takes more than 3-5 seconds to load, which can negatively impact your sales. Therefore, it’s essential to optimize images before uploading them to your website. Here are some suggestions to help improve image optimization:

  • Resize Your Images: Adjust the size of your images to fit the space on your website. Avoid using large images for small areas—resize them to the appropriate dimensions before uploading.
  • Choose the Right Image Format: Select the file type best suited for your images. Use JPEG for images with plain backgrounds, PNG for images requiring transparency, and GIF for animated images.
  • Compress Images: Reduce image file sizes without compromising quality by compressing them. Many free tools are available for this purpose:
Was this page helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *