How to Leverage Browser Caching in Firebase hosting

前端 未结 1 1368
囚心锁ツ
囚心锁ツ 2020-12-24 07:13

I have hosted my personal blog on Google\'s firebase. My Blog is based on jekyll. Firebase provides firebase.json file from where owner of project can modify the http header

相关标签:
1条回答
  • 2020-12-24 07:59

    I just make my portfolio website 99/100.

    Google says:

    We recommend a minimum cache time of one week and preferably up to one year for static assets.

        "headers": [ {
          "source" : "**/*.@(eot|otf|ttf|ttc|woff|font.css)",
          "headers" : [ {
            "key" : "Access-Control-Allow-Origin",
            "value" : "*"
          } ]
        }, {
          "source" : "**/*.@(js|css)",
          "headers" : [ {
            "key" : "Cache-Control",
            "value" : "max-age=604800"
          } ]
        }, {
          "source" : "**/*.@(jpg|jpeg|gif|png)",
          "headers" : [ {
            "key" : "Cache-Control",
            "value" : "max-age=604800"
          } ]
        }, {
          // Sets the cache header for 404 pages to cache for 5 minutes
          "source" : "404.html",
          "headers" : [ {
            "key" : "Cache-Control",
            "value" : "max-age=300"
          } ]
        } ]
    

    Use this, it works for me.

    0 讨论(0)
提交回复
热议问题