使用Appcache与CodeIgniter [英] Using Appcache with CodeIgniter
问题描述
尝试让Appcache与CI一起使用几个小时,但仍然无法正常工作。
背景:
我使用IIS服务器。我已经测试了Appcache通过将需要缓存在一个简单的文件夹中的清单文件和PHP文件,它的工作,所以我很确定服务器环境是好的。
说我要缓存下面的网址
http://mydomain.com.au/myapp/index.php/test/index
这是我的清单.php(我不知道哪一个会工作,所以我在CACHE下放2行,他们都引用相同的视图文件)
<?php
header('Content-Type:text / cache-manifest');
echoCACHE MANIFEST
CACHE:
index.php
http://mydomain.com.au/myapp/index.php/test/index
;
?>
下面是我的视图文件(index.php)放在视图文件夹当然
<!DOCTYPE HTML>
< html manifest =manifest.php>
< body>
这是一个测试
< / body>
< / html>
问题是,我应该将此清单文件放在哪里?我应该在CACHE下列出什么文件?有没有任何例程,我需要跟随,如果我想使用appcache与CI?
我试图把它放在同一个视图文件夹,在一个公共文件夹
您可以使用 index()
方法创建 Manifest
控制器,并使 /index.php/manifest
返回 CACHE MANIFEST
文档(带有适当的标题)。
然后在页面上加入
< html manifest =/ myapp / index.php / manifest >
其他注意事项:
- 应用程序缓存使用urls而不是文件 - 因此它不知道index.php和index.php / index(etc)是同一个文件。
- 如果html文件包含清单,则该文件会自动缓存,因此您不必在CACHE:指令中明确包含该文件。 (您只需要在清单中显式列出其他css / js文件等)
- ,请不要使用完整的网址( http:// ... ),只是路径本身( / myapp / index ... )。
- 我强烈推荐你再次浏览Application Cache文档,一切正确。这是一个非常棘手的事情,以正确工作。
Been trying to make Appcache works with CI for several hours but still couldn't get it work.
Background:
I'm using IIS server. I've tested the Appcache by putting the manifest file and the php file that needs to be cached in a simple folder, it worked, so I'm pretty sure the server environment is good.
Say I want to cache the url below
http://mydomain.com.au/myapp/index.php/test/index
Here's my manifest.php (I don't know which one will work so I put 2 lines under CACHE, they all refer to the same view file)
<?php
header('Content-Type: text/cache-manifest');
echo "CACHE MANIFEST
CACHE:
index.php
http://mydomain.com.au/myapp/index.php/test/index
";
?>
Below is my view file(index.php) placed in the view folder of course
<!DOCTYPE HTML>
<html manifest="manifest.php">
<body>
this is a test
</body>
</html>
Question is, where should I put this manifest file? And what file I should list under CACHE? Is there any routine that I need to follow if I want to use appcache with CI?
I've tried putting it in the same view folder, in a public folder(outside of application folder) with no luck.
Thank you in advance.
You can make a Manifest
controller with just an index()
method, and make /index.php/manifest
return the CACHE MANIFEST
document (with appropriate headers).
And then include that on the page with
<html manifest="/myapp/index.php/manifest">
Additional notes:
- app cache works with urls, not files — so it has no idea that index.php and index.php/index (etc) are "the same file".
- if a html file includes a manifest, that file is cached automatically, so you don't have to explicitly include that in the CACHE: directive. (You only need to explicitly list additional css/js files, etc)
- in the manifest, don't use the full URL (http://…), just the path itself (/myapp/index…).
- I highly reccomend you go through the Application Cache documentation once again just to make sure you've understood everything correctly. It's a really tricky thing to get working correctly.
这篇关于使用Appcache与CodeIgniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!