I got the solution myself. What you have to do is, put the following iframe in the online version like this
<body>
<iframe src="http://site.com/index.php/m/m_offline/" width="0" height="0"></iframe>
It will cache the offline version. Remember to add the manifest file in your offline version. hope this helps to someone else as well.
solved Run offline web app when user is offline