You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

appcache-node

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appcache-node

appcache-node =============

0.1.0
Source
npm
Version published
Weekly downloads
1
-91.67%
Maintainers
1
Weekly downloads
 
Created
Source

appcache-node

###Let their browsers do the work

####In any HTML page you wish to cache..

<html manifest="app.cache"> 

####In the NodeJS/Express app.js..

require('appcache-node')({files: []}, app)

Server generates an app.cache file, so HTML5 Application Cache will force browsers to load their local copy.
This makes for massive decrease on your server load.

Any html file served from your site declared with will be cached. You can see the entire app cache in Chrome by going to chrome://appcache-internals

You choose whatever JS and CSS your page uses, to cache as well. Use the files array..

require('appcache-node')({files: [
	'http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css'
	, 'http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js'
]}, app)

When you restart your app, the app.cache is rebuilt and so cache cleared.
or here's a trick to have the cache reset every hour, if you want browsers to have to reload periodically.

function docache(){
	require('./appcache.js')({files: [
			// no need to include html files that start with <html manifest="app.cache">
			'http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css'
			, 'http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js'
	]}, app);
}

docache();
setInterval(docache, 1000*60*60);

####Options Use an alternate name for the cache file.. http://localhost:3000/myname.cache

require('appcache-node')({path: 'myname.cache'}, app);

####Tests A test web server and example is included in this directory.

$ node tests-server

Go to http://localhost:3000
http://localhost:3000/app.cache to see raw cache file.

More about the HTML5 Application Cache:
http://www.w3schools.com/html/html5_app_cache.asp

Keywords

util

FAQs

Package last updated on 06 Jun 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts