好吧,让我先坦白。我错误地在我的 index.html
中添加了 365 天的到期日期文件。我现在对 JS 文件进行了更改,该文件更改了我的 index.html
中导入的名称。现在它试图导入错误的文件。哎呀。
所以我想让我们将默认文件名更改为未缓存的其他名称。
我现在拥有的
在我的 Angular 项目中,我更改了所有build设置,所以现在我的 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
问题:
Google 似乎仍在提供 index.html
,尽管说实话我不太确定如何检查。如何告诉它提供 main.html
作为默认文件?
编辑 1
当我访问www.my-domain.com
时它仍然提供旧的index.html
。但是当我转到<project>.appspot.com
时(谷歌网址)我没有去过,我猜其他人在相当长的一段时间内也没有去过,(没有缓存)它可以工作。
似乎要更改 index.html
的名称对于缓存提供者来说并不重要,重要的是它们从 /
获取数据。 。我问了另一个有关重定向到另一个 URL /
的相关问题=> app
( Redirect base `/` path to folder in Google App Engine )
<小时/>编辑2
使用此处的技术( https://www.maxlaumeister.com/blog/how-to-use-google-app-engine-as-a-free-redirect-server/ )我能够实现重定向,因此当用户加载 /
时服务器重定向到 /app/
。对于未缓存的appspot.com
来说,这非常有效网址。我的自定义域仍然不起作用。
我非常确定某个中间人(ISP 或一级提供商)正在将整个 GET 请求缓存到 /
。不仅仅是index.html
或服务器响应 /
我不确定我还有什么其他想法。还有其他方法可以破坏此缓存吗?
最佳答案
You can achieve this by modifying your
app.yaml
file and add a handler as in the example shown below:
在此处提供 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
所在的文件夹。您可能有以下内容看起来不一样。
关于javascript - 在 Google App Engine 上重命名 index.html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58687038/