Fix Google PageSpeed leverage browser caching in htaccess
To optimize browser caching in htaccess, simply add the following code inspired by a Stack Overflow thread [1] in your htaccess file :
It will allow you not only to pass the Google PageSpeed leverage browser caching test, but most importantly to speed up your website access time.
For example, this allowed me to pass the Google PageSpeed [2] test leverage browser caching [3] (along with Eliminate render-blocking JavaScript and CSS in above-the-fold content [4]) on a website, going up from a score of 51 on mobile (Fig 1) to 72 (Fig 2), and up from 59 (Fig 3) to 79 on desktop (Fig 4).

Yoann Bierling is a Web Publishing & Digital Consulting professional, making a global impact through expertise and innovation in technologies. Passionate about empowering individuals and organizations to thrive in the digital age, he is driven to deliver exceptional results and drive growth through educational content creation.
Explore Your Business Potential: Discover Our Range of Transformative Courses Today!
Unveil the power of knowledge with our diverse array of courses, from Operational Procurement in S/4HANA to SEO essentials. Elevate your expertise and drive success in your business ventures.
Get your course