小编zev*_*vdg的帖子

Firebase托管:如何防止缓存SPA的index.html

我在firebase上托管SPA,几乎所有路径都被重写index.html.我正在使用基于webpack hash的缓存清除,所以我想总是阻止缓存我的index.html而不是任何其他文件.我发现这样做非常困难.具体来说,我的文件布局如下所示

/
??? index.html
??? login.html
??? js
?   ??? login.ba22ef2579d744b26c65.bundle.js
?   ??? main.6d0ef60e45ae7a11063c.bundle.js
??? public
    ??? favicon-16x16.ico
Run Code Online (Sandbox Code Playgroud)

"sources": "index.html"在从文档中读到这个引用之前,我开始天真.

无论使用glob表示法的任何重写规则如何,每个定义都必须具有与原始请求路径匹配的源键.

好的,所以不是一个简单的glob指定我想要这些头文件的文件,我想我需要一个路径.由于大多数路径重定向到index.html,我需要一个glob,它排除了我不想放置这些头的所有路径.

作为参考,我的firebase.json托管部分如下所示:

{
  "hosting": {
    "public": "dist",
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ],
    "cleanUrls": true,
    "trailingSlash": false,
    "headers": [
      {
        "source": <<<WHAT-GOES-HERE?>>>,
        "headers": [
          {
            "key": "Cache-Control",
            "value": "no-cache, no-store, must-revalidate"
          },
          {
            "key": "Pragma",
            "value": "no-cache"
          },
          {
            "key": "Expires",
            "value": "0"
          }
        ]
      } …
Run Code Online (Sandbox Code Playgroud)

cache-control firebase single-page-application firebase-hosting

21
推荐指数
2
解决办法
5742
查看次数

在不同"路径"上具有相同名称的firestore集合的索引

在我的firestore数据库中,我在层次结构的不同部分使用相同的集合名称.例如,想象一个类似stackoverflow的站点,其中包含以下2个集合

/questions/{questionId}/votes/ /questions/{questionId}/answers/{answerId}/votes/

所以现在我想在这两个集合中的一个上创建一个索引.我希望firestore需要某种"路径与通配符",就像我上面用来识别要编入索引的数据一样.但是,相反,它们只需要集合名称:在这种情况下,"投票".

因此,如果我在"投票"上加上一个索引,它是否适用于这两个集合?有没有办法在其中一个集合上放置索引而不是另一个?使用唯一的集合名称来避免此问题是最佳做法吗?

indexing firebase google-cloud-firestore

8
推荐指数
1
解决办法
1163
查看次数