Skip to content

Commit

Permalink
Significantly speed up page loads when the website is served locally …
Browse files Browse the repository at this point in the history
…by caching docs in memory
  • Loading branch information
hramos committed Feb 4, 2017
1 parent 10a29aa commit 1cbf79d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"glob": "6.0.4",
"jsdoc-api": "^1.1.0",
"jstransform": "11.0.3",
"memory-cache": "^0.1.6",
"mkdirp": "^0.5.1",
"optimist": "0.6.0",
"react": "~0.13.0",
Expand Down
8 changes: 7 additions & 1 deletion website/server/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var optimist = require('optimist');
var path = require('path');
var removeMd = require('remove-markdown');
var extractDocs = require('./extractDocs');
var cache = require('memory-cache');
var argv = optimist.argv;

function splitHeader(content) {
Expand Down Expand Up @@ -135,7 +136,12 @@ function execute() {
);
}

extractDocs().forEach(function(content) {
var extractedDocs = cache.get('extractedDocs');
if (!extractedDocs) {
extractedDocs = extractDocs();
cache.put('extractedDocs', extractedDocs);
}
extractedDocs.forEach(function(content) {
handleMarkdown(content, null);
});

Expand Down

0 comments on commit 1cbf79d

Please sign in to comment.