Using Appcache with CodeIgniter

核能气质少年 提交于 2019-12-06 07:59:28

问题


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.


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!