views:

83

answers:

3

I have a simple php driven website running and I'm trying to figure out how it treats php pages. Some of my php documents are routing logic and some just includes for individual pages. How do i go about making this work offline?

What I though was that I'd have to re-create the routing logic in javascript. Is that my only option? In that case, is it even possible to have the site be driven by php while online and switch to JS offline? I can't make sense of it.

+1  A: 

It is important to remember that PHP is processed on the server. The result of your PHP code is all that is sent to your browser. Your browser has absolutely no knowledge that PHP was even used to make the page!

If you have some dynamic code that must run offline, then you must use Javascript. If this is just for testing on your own machine, put a web server running PHP on your dev machine and acccess it via http://localhost.

Brad
Can the manifest cache .php files though? Let's say if I have .php files that contain actual PHP and some that only contain html but have a .php extension.
Serg Chernata
The file name extension has absolutely **nothing** to do with the file type. File type is determined by the content type HTTP header.
Brad
+1  A: 

HTML5 offline caching does not work to make your pages interact; it works only to make a particular page available offline. Basically, it works on a URL-by-URL basis. If you absolutely need offline functionality, you will be forced to make it work in JS.

Also, make sure your manifest includes all resources used by all pages.

Hope this helps!

mattbasta
+1  A: 

If your site is fairly static, HTML5's cache manifest may get you most of the way there. Have PHP output a cache.manifest file in the correct format with all your routing system's URLs and those URLs will be stored locally in a compliant browser. Attempting to access them will pull them out of the cache if possible.

If you're looking for something more dynamic, though, you're going to have to do more legwork.

Here's some good info on offline caching.

ceejayoz