New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

html-cache

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-cache

Cache html content into RAM or Drive

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

html-cache

Cache html content into RAM or Drive

Tieng Viet khong dau Tieng Viet khong dau

Install

$ npm install html-cache

Usage

Basic

var htmlCache = require('html-cache');

html.save('/home', '<!DOCTYPE html><html><body><h1>Home</h1></body></html>');

console.log(html.get('/home'));

Express

var express = require('express');
var htmlCache = require('html-cache');

var app = express();

app.set('views', './views');
app.set('view engine', 'pug');

app.get('/', (req, res) => {
	if (htmlCache.isCache(req.url)){
    	res.send(htmlCache.get(req.url));
    } else {
    	res.render('default/index', (err, html) => {
        	htmlCache.save(req.url, html);
            return html;
        });
    }
});

app.listen(3000);

API

htmlCache.isCache( key ) [true/false]

htmlCache.save( key, value )

Save cache data

htmlCache.get( key ) [string]

Get cache data

htmlCache.remove( key ) [true/false]

Remove cache by key name

htmlCache.removeOldest()

Remove oldest cache

htmlCache.clear()

Remove all cache

htmlCache.total() [number]

Demo

See here

License

MIT

Keywords

HTML

FAQs

Package last updated on 21 Jul 2016

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