cheesebread
v1.4.0
Published
A delicious and easy to cook CDN file caching for offline development environments.
Downloads
23
Maintainers
Readme
cheesebread - Pão de Queijo
A delicious and easy to cook CDN file caching for offline development environments.
npm start
Type: http://localhost:3000/target_url
where target_url
is an online address, for example: http://localhost:3000/https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png
The first time you hit that URL it will download, cache and provide the file. The subsequent attempts will access from the cache.
Install and run
NPM CLI:
npm install cheesebread -g
cheesebread --help # Command-line help
cheesebread # Start the server
NPM Project:
npm install cheesebread --save-dev
Starting with Express (you can add to your current application).
const http = require('http');
const express = require('express');
const cheesebread = require('cheesebread');
const options = {
dir: 'cache',
externalUrl: 'localhost:3000/proxy',
log: true
};
const app = express();
app.use('/proxy', cheesebread(options)))
const server = http.createServer(cheesebread({ dir, externalUrl, log }));
server.listen(3000, '127.0.0.1', () => {
console.log(`Cheese Bread server is listening on ${externalUrl}/`);
});
Docker:
docker pull gartz/cheesebread
docker run -p "3000:3000" gartz/cheesebread # Start docker container
Purge the cache
Delete all files from the folder: ${home}/.cheese-bread-js/cache
also known as ~/.cheese-bread-js/cache
Environment options
- PORT (3000): Define the server port
- HOST (127.0.0.1): Define the host IP
- CACHE_DIR (~/cheese-bread-js/cache): Define where the cache files will be saved
- LOG (true): Display log information in the output
- EXTERNAL_URL (http://${HOST}:${PORT}): URL used to access the server
Todo
- Create a wildcard to white-list target URLs
Motivation and Name
We want to show a project on CES that should run offline, and we need files from CDN to be cached in our Docker local instance.
On @gartz vocation at the hotel he write this server script that would allow to accomplish the task.
To choose the name @brainTrain established that being a JS project it must have a name that isn't semantic to it. @ptubig suggested that it should be an Brazilian name, and @tjohnson4 gave the idea to call it "Pão de queijo", what we translated to Cheese Bread.