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.
来源:https://stackoverflow.com/questions/19087780/using-appcache-with-codeigniter