dongshi2836 2014-11-05 03:40
浏览 141

即使修改了HTML页面,App引擎仍返回304

I have an angular js app whose main container page "index.html" is updated each version. This is hosted in app-engine that I've built using Go. The server end offers straight serving of the html views and the static content as well as a restful API.

It all works great until I push a new version then I have to hard reload the page to avoid getting a 304.

My app.yaml file is really basic right now:

handlers:
- url: /.*
  script: _go_app

I'm not setting any caching policies yet so I understand app engine will default the caching of static files for 10 minutes.

What's happening?

  • 写回答

1条回答 默认 最新

  • duanlan7903 2014-11-05 16:55
    关注

    I believe I have found the answer.

    Two things were bothering me about this:

    Firstly, I knew I wasn't handling static files as efficiently as I could have been, it was a job I hadn't gotten around to yet but the static files were being delivered via routing code in the main go script rather than declared in the app.yaml

    Using the latter method would let app engine do the work rather than my script and hopefully save a few precious processor cycles.

    Secondly I wasn't exactly sure how index.html was being served when the path was "/", it was just working. I know that various web servers (Apache, IIS, etc) have a default page and app engine seemed to be working the same way.

    So when I was deciding that each request didn't require any dynamic script I would simply serve it with the following code:

    http.ServeFile(w, r, r.URL.Path[1:])
    

    This magically turned "/" into "/index.html" for me but appears to have the caching bug described above. I will take this up with the Go community.

    As for the fix, adding the page as a static file to the app.yaml made this work:

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

    I will make sure I add all the other static folders too.

    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序