by Devin Yang
(This article was automatically translated.)

Published - 7 years ago ( Updated - 7 years ago )

What is PageSpeed ​​Insights?

PageSpeed ​​Insights is an analysis tool provided by Google, which analyzes and optimizes our website according to the so-called best practices of the website (Web Best Practices).
I can use his suggestions to optimize the website.

How to optimize?

The optimization type can be divided into the entire webpage structure and settings, including the optimization of webpage image files.
Since the hosting provider of the web hosting website I am currently using is Bluehost, and he uses Apache Web Server,
So here I share the .htaccess setting method used in my project, through the following setting can improve a lot of scores. ( optimized part )
After modifying .htaccess, please be sure to confirm whether it is feasible. Incorrect settings will cause the host to display a 500 error.
Very important , ExpiresDefault should be cached for at least 1 week, which made me add 10 points .
content_copy
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
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.*


## EXPIRES CACHING ##

Expires Active On
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 week"
ExpiresByType text/css "access 1 week"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 week"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 week"
result Here are the results of my crazy optimizations using PageSpped Insights. finally electricity The brain version has 95 points.
livewire/content-tags Tags: web-hosting Devin Yang Feel free to ask me, if you don't get it.:) Follow livewire/comments No Comment Post your comment Login is required to leave comments
close livewire/similar-stories About Me Disclaimer Privacy Licenses © 2025, made with favorite by Devin Yang for a better web. livewire/content-search backspace × livewire/block-content-lists Run OpenSpeedTest with phpenv format_align_left Read Article About the operation of --env in Laravel's artisan This article uses Laravel 9.40.1 for operation. I believe many people know...more format_align_left Read Article Use HAProxy to remove the /mail path of the Sysnolgy Mail Station This article explains the version of DSM7. The Package Center of Synology...more format_align_left Read Article HAProxy and fastapi HAProxy can use the definition of acl to determine which backend the request should direct to. This ...more format_align_left Read Article How do I create a fastapi runtime environment with phpenv phpenv php laravel runs HAProxy, and automatically applies for and updates...more format_align_left Read Article livewire/content-pages ‹‹ 1 2 3 4 5 6 ... 50 51 ›› window.livewire = new Livewire();window.Livewire = window.livewire;window.livewire_app_url = '';window.livewire_token = 'diUllLScZ13cAytNhpLjJIIqQNiu4rcNIjQKnH9A';window.deferLoadingAlpine = function (callback) {window.addEventListener('livewire:load', function () {callback();});};let started = false;window.addEventListener('alpine:initializing', function () {if (! started) {window.livewire.start();started = true;}});document.addEventListener("DOMContentLoaded", function () {if (! started) {window.livewire.start();started = true;}}); /* var usertz = moment.tz.guess(); */ var searchStyle = function() { if ($(window).scrollTop() >= 100) { $("#search").parent().removeClass("has-white").addClass("has-rose"); $("#search").css({ 'color': 'gray' }); } else { $("#search").parent().removeClass("has-rose").addClass("has-white"); $("#search").css({ 'color': 'white' }); } if (window.width < 992) { $("#search").parent().removeClass("has-white").addClass("has-rose"); $("#search").css({ 'color': 'gray' }); } } $(window).resize(function() { if (document.body.clientWidth <= 992) { /* $("#search").parent().removeClass("has-white").addClass("has-rose"); $("#search").css({'color':'gray'}); */ //console.log(document.body.clientWidth); } }); var cleanSearch = function(e) { if (e.which == 21) { Livewire.emitTo('content-search', 'clean'); $("#search").focus(); } } document.getElementById("search").addEventListener("keyup", function(e) { cleanSearch(e); }); //searchStyle(); window.addEventListener('search-updated', event => { $("#search").focus(); }) $(document).on("keydown", function(e) { var code = e.keyCode; }); $(document).on("keypress", function(e) { if (!$("#search").is(":focus")) { console.log("B"); e.preventDefault(); } var code = e.keyCode; console.log(code); if (code == 47) { location.href = "/"; //$('#searchModal').modal('show'); } cleanSearch(e); }); var touchSearch = function(event) { $("#contentModal").modal("hide"); $(event.target).focus(); } $('#searchModal').on('shown.bs.modal', function() { $("#btnSearchModal").parent().fadeOut(); $('#search').trigger('focus'); }) $('#searchModal').on('hidden.bs.modal', function() { $("#btnSearchModal").parent().fadeIn(); $(document).trigger('focus'); }) var modalClose = function(modalId) { console.log("close modalId" + modalId); $("#" + modalId).modal("hide"); } $("#contentModal").on("shown.bs.modal", function(event) { var modal = $(this); modal.find("pre:has('code')").prepend('<span class="material-icons copy_code_to_text" onClick="copy_code_to_text(event,true)">content_copy</span>'); $("#contentModalCloseButton").show(); }); $('#contentModal').on('hidden.bs.modal', function() { var page = Livewire.emitTo('block-content-lists', 'getPage'); window.history.pushState('page', '3C Tech Center', "/?page=" + page); $("#contentModalCloseButton").hide(); }); Livewire.hook('element.initialized', (el, component) => { $("code").each(function(i, elm) { //Prism.highlightAll(elm); }); }) window.addEventListener('set-content-url', event => { var url = event.detail.url; var title = event.detail.title; var elm = $("div.modal-body").html(); $("#searchModal").modal("hide"); Prism.highlightAll(elm); FB.XFBML.parse(); try { window.history.pushState('page', title, url); document.title = title; } catch (e) { console.log(e); } $("#contentModal").modal("show"); }) //localStorage.clear(); var go_privacy = function() { localStorage.setItem("notify_cookie", "1"); location.href = "/privacy"; } var switch_lang = function(event,lang){ event.preventDefault(); const regex = /(^https:\/\/)\w+(\..+)/gm; var url = location.href.replace(regex,"\$1"+lang+"\$2"); location.href = url; } var cookie_notify = function() { toastr.options = { "closeButton": true, "debug": false, "newestOnTop": true, "progressBar": false, "positionClass": "toast-bottom-full-width", "preventDuplicates": false, "onclick": null, "showEasing": "swing", "hideEasing": "linear", "timeOut": 6000000, "extendedTimeOut": 6000000, "iconClasses": {"warning":"dark"} } if (localStorage.getItem("notify_cookie") == undefined) { toastr.warning( `In order to provide you with better services, this website uses cookies. By continuing to browse the web, you agree to our cookies policy. To understanding <button class='btn btn-danger btn-sm' onClick="go_privacy()" type="button" class='text-primary'><b>PRIVACY</b></button> ` ); } } cookie_notify(); if (window.history && history.pushState) { // check for history api support this.addEventListener('popstate', function(event, state) { modalClose('contentModal'); }); } var copy_code_to_text = function(event, is_modal=false) { toastr.remove() toastr.options = { "closeButton": false, "debug": false, "newestOnTop": false, "progressBar": true, "positionClass": "toast-top-right", "preventDuplicates": false, "onclick": null, "showDuration": "300", "hideDuration": "1000", "timeOut": "3000", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" } event.preventDefault(); var x = document.createElement("textarea"); if(is_modal){ var code = $(event.target).next(); console.log(code.text()); x.value = code.text(); $(event.target).append(x); x.select(); document.execCommand("copy"); x.remove(); }else{ x.value = $(event.target).parent().find("code").text(); document.body.appendChild(x); x.select(); document.execCommand("copy"); x.remove(); } toastr.info("已拷贝!") } $("pre:has('code')").prepend('<span class="material-icons copy_code_to_text" onClick="copy_code_to_text(event)">content_copy</span>');
In order to provide you with better services, this website uses cookies. By continuing to browse the web, you agree to our cookies policy. To understanding