2011-01-26 68 views
1

我試圖讓iPhone緩存一個HTML5的Web應用程序,這樣我可以在離線時使用它。網絡應用程序在www.prism.gatech.edu/~gtg880f,我沒有做到。我借用它只是爲了試用它。爲什麼我的iPhone Web應用程序沒有緩存並在離線模式下工作?

只有3個文件: 的index.html index.js 的style.css

我修改的index.html包括<html manifest="offline2.manifest"><meta content="yes" name="apple-mobile-web-app-capable" />,使其看起來充滿屏幕的離線Web應用程序。

我offline2.manifest文件如下:

CACHE MANIFEST 
index.html 
index.js 
style.css 
debug.js 

NETWORK: 

CACHE: 

PS:debug.jsJonathan Stark

當我使用firefox時,它正確緩存它,並且我能夠離線使用web應用程序。但是,它在鉻和Safari瀏覽器中都失敗了。

在Chrome中,我得到了下面的調試消息:

Application Cache Checking event 
Application Cache Error event: Invalid manifest mime type (text/plain) http://www.prism.gatech.edu/~gtg880f/offline2.manifest 

我GOOGLE了明顯的MIME類型和它提到一些關於.htaccess,什麼不可以,我其實也不太清楚這意味着什麼。按照說明,我去了etc/apache2/httpd.conf並從無更改ALLOWOVERIDE ALL

這似乎並沒有解決任何問題,但我仍然得到相同的錯誤信息。

簡而言之,我想要做的就是使用iPhone上的Safari瀏覽器訪問www.prism.gatech.edu/~gtg880f並將其保存到我的主屏幕。然後,關閉3G和WiFi,並仍然使用網絡應用程序。

編輯:試從第一回答roryf: 仍然無法正常工作。我是否想編輯/etc/apache2/httpd.conf中的httpd.conf文件?我正在使用Mac OSX。我說根據本條

<IfModule mime_module> 
    # 
    # TypesConfig points to the file containing the list of mappings from 
    # filename extension to MIME-type. 
    # 
    TypesConfig /private/etc/apache2/mime.types 

    # 
    # AddType allows you to add to or override the MIME configuration 
    # file specified in TypesConfig for specific file types. 
    # 
    #AddType application/x-gzip .tgz 
    # 
    # AddEncoding allows you to have certain browsers uncompress 
    # information on the fly. Note: Not all browsers support this. 
    # 
    #AddEncoding x-compress .Z 
    #AddEncoding x-gzip .gz .tgz 
    # 
    # If the AddEncoding directives above are commented-out, then you 
    # probably should define those extensions to indicate media types: 
    # 
    AddType application/x-compress .Z 
    AddType application/x-gzip .gz .tgz 
    AddType text/cache-manifest manifest # added to allow HTML5 offline caching 

回答

0

看起來你需要的MIME類型.manifest文件設置爲text/cache-manifest在你的Apache配置,這可能是你閱讀的.htaccess(要做到這一點的一種方式)的東西。

添加這.htaccess文件應該工作:

AddType text/cache-manifest manifest 
+0

還不行。 – okysabeni 2011-01-26 19:01:14

+0

檢查爲該請求設置了什麼樣的mime類型,會告訴你你的apache配置是錯誤還是清單。 – roryf 2011-01-26 19:53:30

0

我的工作的web應用程序剪切複製在緩存中的文件名:該.manifest的文件的一部分。就像這樣:

CACHE MANIFEST 
index.html 
index.js 
style.css 
debug.js 
CACHE: 
index.html 
index.js 
style.css 
debug.js 
NETWORK: 

我也包括在此在同一Web服務器的目錄清單.htaccess文件:

AddType text/cache-manifest .manifest manifest 
0

我有同樣的煩惱調試在iPhone上的離線Web應用程序,以及。該應用在Chrome和Safari中正常運行(均適用於Windows)。在iPhone上重新啓動終於成功了。希望這可以幫助。

1

我剛剛檢查過,它看起來像你的清單文件仍然作爲文本/純文本。以下是您可以採取的解決問題的步驟。

  1. 創建一個在同一目錄清單文件名爲.htaccess

  2. (有時創建與開始於一個點是在命令行上這樣做的一個文件名的文件的唯一途徑)新文件
  3. 編輯文件,插入下面一行到它:

    AddType text/cache-manifest manifest 
    
  4. 轉到http://web-sniffer.net/並插入路徑到您的清單文件,以確認它被送達正確的MIME類型。看來你需要在這裏使用的路徑是http://www.prism.gatech.edu/~gtg880f/offline2.manifest

0

或者,你可以簡單地做一個名爲:manifest.php,並把它這個內容;

<?php 
    header('Content-Type: text/cache-manifest'); 
    echo "CACHE MANIFEST\n\n"; 
    echo "CACHE:\n"; 

    $hashes = ""; 
    $dir = new RecursiveDirectoryIterator("."); 
    foreach(new RecursiveIteratorIterator($dir) as $file) { 
    if ($file->IsFile() && 
    $file != "./manifest.php" && 
    substr($file->getFilename(), 0, 1) != ".") { 
     echo $file . "\n"; 
     $hashes .= md5_file($file); 
    } 
    } 

    echo "\n# Hash: " . md5($hashes) . "\n"; 
?> 
1

嘗試將文件擴展名更改爲不同的內容。

我有同樣的問題,當我保存它作爲cache.manifesto - 改變了htaccess來

AddType text/cache-manifest .manifesto 

,並指出它在HTML文件作爲

<html manifest="cache.manifesto" > 

它wоrked就好了。

1

這是我做的,以實現在Mac

與我的離線存儲上班打開httpd.conf文件
採取備份。
找到有「AllowOverride」,改變從「無」的值改爲「全部」

某處接近線#198

Options Indexes FollowSymLinks 
AllowOverride None 
相關問題