Http
CORS 跨網域資訊存取 Cross origin resource sharing
Use Preflight request to negotiate the request can be CORS or not.
the negotiated request use HTTP method called OPINON.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS
使用情境:
在網頁端直接存取其他WebServer 提供的API,對網頁端的好處是無需建置WebServer提供網頁檔案。直接在網頁端指定API HOST
Cache
nginx
Use sendfiles off (無論如何nginx 都會重新讀取檔案)
CloudFlare
Add hash in app file such as bundle.js
Cache-control 指定cache多久才過期,e.g. max-age=3600
no-store : 無cache
no-cache: 會發起request 檢查e-tag 或 Last-modfied
no-store, no-cache, private, public, max-age=3600
一次可以指定多個值,並以,分隔。
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
304 Not modified
There is a cache file at browser, and send if-modified-since in request header, if doc is not modified, 304 will return.
200 OK (from cache)
Doesn't execute request to server, use stored file at cache instead.
http://fanli7.net/a/bianchengyuyan/JS-HTML-WEB/20140309/476996.html
https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching
Cache-Control 會影響browser 是否要檢查browser cache, 如果尚在時間內則使用browser端的檔案而不發起request
若否,比方說max-age = 0 則進到if-modifed-since 與etag 的確認
Last updated
Was this helpful?