[Google Gears] LocalServer Module API
LocalServer Module
출처:
http://code.google.com/apis/gears/api_localserver.html
네트워크 연결이 끊긴 상태에서도 웹 어플리케이션의 HTTP 리소스들을 로컬에 저장하고 제공해주는 역할을 한다.
Resource Stores
- ResourceStore : 자바스크립트를 이용하여 임시의 URL들을 캡쳐링
- ManagedResourceStore : manifest 파일에 선언된 URL들을 캡쳐링
Updating of cached resources
- ManagedResourceStore는 manifest 파일의 버전이 변경될 경우 자동적으로 업데이트를 한다.
(checkForUpdate() 메소드를 이용)
- ResourceStore는 웹 어플리케이션에 의해 변경된다. (자동 업데이트 X)
Local serving of cached resources
- LocalServer는 HTTP/HTTPS 요청을 캐싱된 데이터를 이용하여 상황에 맞게 제공해준다.
- 네트워크 상태와는 상관없이 요청된 URL이 캐싱된 경우에는 캐싱된 리소스들로 처리한다.
LocalServer Class
로컬서버는 Gears Factory를 통하여 생성된다.
생성소스보기
메소드보기
ManagedResourceStore Class
ResourceStore Class
FileSubmitter Class
Manifest File
{
// version of the manifest file format
"betaManifestVersion": 1,
// version of the set of resources described in this manifest file
"version": "my_version_string",
// optional
// If the store specifies a requiredCookie, when a request would hit
// an entry contained in the manifest except the requiredCookie is
// not present, the local server responds with a redirect to this URL.
"redirectUrl": "login.html",
// URLs to be cached (URLs are given relative to the manifest URL)
"entries": [
{ "url": "main.html", "src": "main_offline.html" },
{ "url": ".", "redirect": "main.html" },
{ "url": "main.js" }
{ "url": "formHandler.html", "ignoreQuery": true },
]
}
댓글
댓글 쓰기