Debugging
It can be tough to debug apps that use the offline application cache, because there’s very little visibility into what is going on. You may find yourself constantly wondering if your files have downloaded or if you are viewing remote or local resources. Plus, switching your device between online and offline modes is not the snappiest procedure and can really slow down the develop-test-debug cycle.
One thing you can do to help determine what’s going on when things aren’t playing nice is to set up some console logging in JavaScript.
Note
If you want to see what’s happening from the
web server’s perspective, you can monitor its log files. For example, if
you are running a web server on a Mac or Linux computer, you can open
the command line and run these commands (the $
is the
shell prompt, which you should not type):
$ cd /var/log/apache2/ $ tail -f access?log
This will display the web server’s log entries, showing information such as the date and time a document was accessed, as well as the name of the document. When you are done, press Control-C to stop following the log.
The ?
on
the second line will match any character; on Ubuntu Linux, the filename
is access.log and on the Mac it is
access_log. If you are using
another version of Linux, the name of the file and its location may be
different.
On Windows, you can find IIS7’s log files in C:\inetpub\logs, but you will need to authenticate as an administrative user to access the files (if you navigate to that folder in Windows ...
Get Building Android Apps with HTML, CSS, and JavaScript, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.