开发者

How to make website available offline

I want to make my website available offline even if the user clears the cache and cook开发者_如何转开发ies. Is is possible? Also I am dealing with database. Is is possible to handle databases offline?


  1. A user could store a local copy of a single webpage using Chrome (right click save-as) and it will store all resources (images, css, js) required to fully load the page offline. Other browsers will have similar options.

  2. You can use wget to mirror a whole website for offline browsing.

    wget --mirror --convert-links --html-extension -p http://www.example.com/
    

    of course neither of these options will handle database driven elements of your site/page.

  3. If you want to mock a database or dynamic elements of a page offline then Google Gears is probably the closest to what you are looking for but I think it was deprecated by Google last year.


If your users have modern browsers, try HTML5 Application Cache.

References:

Overview - http://www.html5rocks.com/en/features/offline

Demo - https://jonathanstark.com/labs/app-cache-7/

Tutorial - https://www.html5rocks.com/en/tutorials/appcache/beginner/

Article - http://grinninggecko.com/developing-cross-platform-html5-offline-app-1/


Summary: Click me, I'm the newish thing that browsers now support!

I clicked some of the links found in other answers, and all tools mentioned are deprecated or will/should be soon.

Later when I wasn't connected to the internet, I opened a site operated by Google (either Google Docs or YouTube, I sadly forgot since then) and went to view the page source, as I was curious to see other answers in action. I found something called ORIGIN-TRIAL in the manifest file. After a quick Google search, I found this, which brought me to this, which somehow brought me to the last link:

https://developers.google.com/web/fundamentals/primers/service-workers

In conclusion, use Service Workers now. If you're curious if it now works with all browsers, don't worry. All popular browsers should support it as seen here.


No, if your databases are housed online. then you need a internet connection for the PHP/ASP (whatever you're using to deal with DBs) to connect/communicate to the DB's


For storing data locally and accessing them offline take a look at Gears and Web Storage.

The main problem is what degree of functionality you want to provide with your website. It always requires some work on the client (user) side to "store" aka. save your website offline. You would have to store all your functionality in one page that the user stores (be it a Flash movie or some Javascript-Code).


You can use simple command to download whole website locally with all links working properly.

wget -rk 'http://www.website.com'

For https url you need to add one more property like below :

wget -rk --no-check-certificate 'https://www.website.com'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜