重命名Google App Engine上的index.html [英] Renaming the index.html on Google App Engine
问题描述
好吧,让我先打扫一下.我错误地在index.html
文件中添加了365d有效期.现在,我对JS文件进行了更改,从而更改了index.html
中的导入名称,现在它正尝试导入错误的文件.糟糕!
Ok, let me 1st come clean. I mistakenly added a 365d expiration date to my index.html
file. I've now made a change to a JS file, which changed the name of the import in my index.html
and now it's trying to import the wrong file. Oops.
所以我在考虑让我们将默认文件名更改为其他未缓存的文件.
So I'm thinking let's change the name of the default file name to something else that isn't cached.
在Angular项目中,我已经更改了所有建筑设置,因此现在我的index.html
文件命名为main.html
.即使文件本身被命名为main.html
,并在我的dist文件夹中检查,也没有index.html
,只有main.html
.
In my Angular project, I've changed all the building settings so now my index.html
file is named main.html
. The even the file itself is named main.html
, and checking in my dist folder, there is no index.html
only a main.html
.
我已经将网站托管在Google App Engine上,这是我在构建后用来部署的命令.
I have hosted the site on Google App Engine and this is the command I used to deploy after building.
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
作为默认文件?
Problem:
It seems like Google is still serving up index.html
, though to be honest I'm not really sure how to check. How do tell it to serve up the main.html
as the default file?
当我访问www.my-domain.com
时,它仍然可以容纳旧的index.html
.但是,当我进入一个我从未去过的<project>.appspot.com
(谷歌URL)时,我猜很长一段时间都没有其他人了(没有缓存),它可以工作.
When I visit www.my-domain.com
it still serves up the old index.html
. But when I go to the <project>.appspot.com
(the google URL) which I haven't been to and I'm guessing neither has anyone else in quite some time, (not cached) it works.
似乎更改index.html
的名称对缓存提供程序并不重要,只是它们从/
中获取数据.我问了另一个有关重定向到另一个URL /
=> app
It seems like Changing the name of the index.html
doesn't matter to the cache providers only that they are GETing data from /
. I have asked another related question about redirecting to another URL /
=> app
( ="将基本`/`路径重定向到Google中的文件夹App Engine )
在此处使用该技术( https://www.maxlaumeister.com/blog/how-to-use-google-app-engine-as-a-free-redirect-server/),我能够获得一个重定向工作,因此当用户加载/
时,服务器将重定向到/app/
.对于未缓存的appspot.com
网址,这非常有用.我的自定义域仍然无法使用.
Using the technique here (https://www.maxlaumeister.com/blog/how-to-use-google-app-engine-as-a-free-redirect-server/) I was able to get a redirect working so when the user loads /
the server redirects to /app/
. This works great, for the uncached appspot.com
url. My custom domain still doesn't work.
我很确定某些中间人(ISP或Tier 1提供程序)会将整个GET请求缓存到/
.不仅是index.html
还是服务器对/
I'm pretty sure some middle man (ISP or Tier 1 provider) is cacheing the entire GET request to /
. Not just index.html
or the server response to /
我不确定我还有其他想法.还有其他方法可以破坏此缓存吗?
I'm not sure what other ideas I have. Are there any other ways to bust this caching?
推荐答案
您可以通过修改
app.yaml
文件并添加处理程序来实现此目标,如下所示:
You can achieve this by modifying your
app.yaml
file and add a handler as in the example shown below:
在此处提供main.html
:
Serving main.html
here:
handlers:
- url: /
static_files: app/main.html
upload: app/main.html
投放index.html
,而不是:
Serving index.html
, instead:
handlers:
- url: /
static_files: app/index.html
upload: app/index.html
app
是index.html
和main.html
所在的文件夹.您的外观可能有所不同.
Where app
is the folder in which index.html
and main.html
are located in. You may have something that looks different.
这篇关于重命名Google App Engine上的index.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!