问题
My HTML 5 app is deployed on Tomcat locally, how can I test offline access?
Here's the detailed description:
I've a very simple JSP-based web app wherein I'm trying to test HTML 5 offline cache.
This is how my JSP page looks like (code snippet):
<!doctype html>
<html lang="en" manifest="example.appcache">
And, this is the manifest file:
# Resources that require the user to be online.
NETWORK:
/jsp/date.jsp
FALLBACK:
/jsp/date.jsp /jsp/staticDate.html
The app is deployed on Tomcat 6. I can very well access the date.jsp page when Tomcat is running and I do see the FF popup asking my permission to store data locally. How can i test offline page access? I stopped Tomcat but I see the standard browser error page (Unable to connect error message).
Thanks JJ
回答1:
staticDate.html
is served by Tomcat as well. So you need to keep Tomcat running, but after the browser has cached the website, disable the servlet for date.jsp
.
回答2:
You're doing it wrong. HTML5 offline is for when your internet connection is down, not when the server is down. If you have an internet connection on your computer, then it will try to hit the server, find out Tomcat isn't running, and return a 404 or 503 error.
If your computer's internet connection is down, then the browser should recognize that you have no internet connectivity and then attempt the fallback.
This also assumes you've coded everything correctly and are using an HTML5 browser.
To test, I would suggest disabling your PC/Mac's internet connection.
来源:https://stackoverflow.com/questions/9753580/html-5-testing-offline-cache-with-localhost