首页 > 解决方案 > 在 Google App Engine 上重命名 index.html

问题描述

好的,让我第一次来干净。index.html我错误地在我的文件中添加了 365d 到期日期。我现在对一个 JS 文件进行了更改,该文件更改了我的导入名称,index.html现在它正在尝试导入错误的文件。哎呀。

所以我想让我们将默认文件名的名称更改为其他未缓存的名称。

我现在拥有的

在我的 Angular 项目中,我更改了所有的构建设置,所以现在我的index.html文件名为main.html. 即使文件本身被命名为main.html,并且在我的 dist 文件夹中检查,也没有index.html只有一个main.html.

我在 Google App Engine 上托管了该站点,这是我在构建后用来部署的命令。

gcloud app deploy app.yaml --quiet --project=<project-name>

这是我的app.yaml

api_version: 1

env: standard
runtime: python27
service: <service-name>
threadsafe: yes


handlers:

- url: /(.*\.(css|eot|gz|html|ico|js|map|png|jpg|jpeg|svg|ttf|woff|woff2|pdf|gif))
  static_files: dist/browser/\1
  upload: dist/browser/(.*\.(css|eot|gz|html|ico|js|map|png|jpg|jpeg|svg|ttf|woff|woff2|pdf|gif))
  expiration: "365d"

- url: /.*
  static_files: dist/browser/main.html
  upload: dist/browser/main.html
  secure: always
  expiration: "0s"

skip_files:
 ## bunch of files

问题:

谷歌似乎仍在提供服务index.html,但老实说我不太确定如何检查。如何告诉它main.html作为默认文件提供?


编辑 1

当我访问时www.my-domain.com,它仍然提供旧的index.html。但是当我去我没去过的<project>.appspot.com(谷歌网址)时,我猜在相当长的一段时间内也没有其他人,(没有缓存)它可以工作。

似乎更改名称对index.html缓存提供者无关紧要,只是他们正在从/. 我已经问过另一个有关重定向到另一个 URL 的相关问题/=>app

将基本`/`路径重定向到 Google App Engine 中的文件夹


编辑 2

使用这里的技术(https://www.maxlaumeister.com/blog/how-to-use-google-app-engine-as-a-free-redirect-server/)我能够获得重定向工作,所以当用户加载/服务器重定向到/app/. appspot.com对于未缓存的url ,这很好用。我的自定义域仍然不起作用。

我很确定某个中间人(ISP 或第 1 层提供商)正在将整个 GET 请求缓存到/. 不只是index.html或服务器响应/

我不确定我还有什么其他想法。还有其他方法可以破坏这种缓存吗?

标签: javascriptangulargoogle-app-enginegoogle-cloud-platform

解决方案


您可以通过修改app.yaml文件并添加处理程序来实现此目的,如下例所示:

在这里服务main.html

handlers:
- url: /
  static_files: app/main.html
  upload: app/main.html

服务index.html,而不是:

handlers:
    - url: /
      static_files: app/index.html
      upload: app/index.html

app所在的文件夹在哪里。您可能有一些看起来不同的东西。index.htmlmain.html


推荐阅读