javascript - 在 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
或服务器响应/
我不确定我还有什么其他想法。还有其他方法可以破坏这种缓存吗?
解决方案
您可以通过修改
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.html
main.html
推荐阅读
- docker - PC重启后docker从一开始就运行配置是否正常?
- perl - XS.c:可加载库和 perl 二进制文件不匹配(获取握手密钥 0xc100000,需要 0xc180000)
- html - 在 Github 中,如何让 index.html 在我的托管网站中自动打开
- python - Tkinter:不断更新变量
- git - GitHub:当分支与 master 没有更多共同历史记录时如何重新打开拉取请求
- video-streaming - WebRTC 如何根据自适应比特率确定何时调整视频大小?
- c++ - 使用辅助临时对象方便的“回写”
- vim - 打开 url 时在命令中转义 `#`
- javascript - 使用 `status == true` 时,布尔条件始终为假
- python - 从 SQLite 检索数据时出现语法错误