UWAGA: Tłumaczenie tej strony nie zostało zakończone.
Może być ona niekompletna lub wymagać korekty.
Chcesz pomóc? | Dokończ tłumaczenie | Sprawdź ortografię | Więcej takich stron...
Ten artykuł obejmuje funkcje wprowadzone w Firefoksie 3
Firefox 3 implements much of HTML 5's support for offline caching of web applications' resources. This is done using the application cache -- a collection of resources obtained from a resource manifest provided by the web application.
^
Ponieważ wiele aplikacji sieciowych może udostępniać zasoby (jak i udostępniać je również na tych samych identyfikatorach URI), każda aplikacja internetowa utrzymuje swoją własną pamięć podręczną. Jednakże, zasoby aplikacji są pogrupowane według ich zapisów URI, a także posiadają prostą stan aktualizacji. Stan aktualizacji jest na jednym z poniższych poziomów:
idle / bezczynny
checking / sprawdzanie
downloading / ściąganie
Obecnie tylko wpisy do zasobów są obsługiwane. Firefox jeszcze nie wspiera opportunistic caching or cofanie wpisów; jednakże zaleca się, żebyś ciągle zapewniał białą listę, jeżeli to stosowne, dla przyszłej kompatybilności.
Pamięć podręczna zawiera zawsze przynajmniej jeden zasób, identyfikowany przez jego URI, z przynajmniej jednej z następujących kategorii:
manifest attribute.
html element's manifest attribute. The manifest is downloaded and processed during the application cache update process. Implicit entries must have the same scheme, host, and port as the manifest.
add() method.
The online whitelist may contain zero or more URIs of resources that the web application will need to access off the server rather than the offline cache. This lets the browser's security model protect the user from potential security breaches by limiting access only to approved resources.
^
Cache manifest files must be served with the text/cache-manifest MIME type, and all resources served using this MIME type must follow the syntax for an application cache manifest, as defined here. Cache manifests are UTF-8 format text files and may, optionally, include a BOM character. Newlines may be represented by line feed (U+000A), carriage return (U+000D), or carriage return and line feed both.
The first line of the cache manifest must consist of the string "CACHE MANIFEST" (with a single U+0020 space between the two words), followed by zero or more space or tab characters. Any other text on the line will be ignored.
The remainder of the cache manifest must be comprised of zero or more of the following lines:
Section header Description CACHE:Switches to the explicit section. This is the default section. FALLBACK:Switches to the fallback section. ^
Uwaga: The fallback section is not yet supported by Firefox, and will be ignored.NETWORK:Switches to the online whitelist section. ^
Uwaga: The online whitelist section is not yet supported by Firefox, and will be ignored; however, providing an appropriate online whitelist is strongly recommended.
Cache manifests may switch back and forth from section to section at will (so each section header can be used more than once), and sections are allowed to be empty.
^
Poniżej znajduje się prosty wykaz pamięci podręcznej zmyślonej strony o adresie foo.com.
CACHE MANIFEST # v1 # To jest przykładowy komentarz. http://www.foo.com/index.html http://www.foo.com/header.png http://www.foo.com/blah/blah
W tym przykładzie nie ma sekcji nagłówkowej, dlatego wszystkie linijki danych są zawarte w otwartej sekcji.
Komentarz z linijką "v1" znajduje się tam z dobrych powodów. Ponieważ pamięć podręczna jest aktualizowana tylko wtedy, gdy zostanie zmieniony wykaz(manifest), to, jeżeli zmienisz zasoby (na przykład zmieniając obrazek header.png), wystąpi potrzeba zmiany pliku wykazu, by powiadomić przeglądarkę o potrzebie odświeżenia pamięci podręcznej. Można tego dokonać różnymi sztuczkami na wykazie, lecz zawarcie jego numeru wersji jest dobrym sposobem do osiągnięcia tego efektu.
Aby zlecić Firefoksowi użycie zapamiętania zasobów offline dla podanej strony, należy użyć atrybutu manifest(z ang. wykaz) w elemencie html, jak to uczyniono poniżej:
<html manifest="http://www.foo.com/cache-manifest"> ... </html>
manifest, wysyła event(zdarzenie/wyjątek) checking do obiektu window.applicationCache, wtedy dostaje się do pliku wykazu, podążając według odpowiednich reguł buforowania HTTP. Jeżeli obecnie zapamiętana kopia wykazu jest aktualna, to event(zdarzenie/wyjątek) noupdate jest wysyłane do applicationCache i proces aktualizacji jest zakończony.
noupdate event is sent to the applicationCache, and the update process is complete. Again, this is why if you change the resources, you need to change the manifest file so Firefox knows it needs to re-cache the resources.
applicationCache.add() -- are fetched into a temporary cache, following the appropriate HTTP caching rules. For each file fetched into the cache, a progress event is sent to the applicationCache object. If any errors occur, an error event is sent, and the update halts.
cached event is sent to the applicationCache object.
Ponieważ szkic standardu HTML 5 był jeszcze w trakcie zmian w czasie, gdy zbliżała się data zamrożenia funkcjonalności Firefoksa 3, część możliwości pamięci podręcznej offline nie została zaimplementowana:
Page last modified 23:00, 6 sie 2008 by Mgjbot