Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make website available offline

I want to make my website available offline even if the user clears the cache and cookies. Is is possible? Also I am dealing with database. Is is possible to handle databases offline?

like image 376
rdp Avatar asked Feb 01 '11 10:02

rdp


People also ask

Can a website be used offline?

Chrome and Firefox come with an Offline mode that'll let you load a page from browser cache in case you don't have internet connectivity. When you enable this mode, the browser will give you the option to load web pages from the cache.


3 Answers

  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.

like image 144
Joel Avatar answered Oct 27 '22 01:10

Joel


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/

like image 35
jpillora Avatar answered Oct 26 '22 23:10

jpillora


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.

like image 35
Xan Avatar answered Oct 27 '22 00:10

Xan