Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

preload concated files in manifests

  • Loading branch information...
commit e169f2b98436a0eaaa0d6670864383280ede7a3a 1 parent 93f13a7
@jairajs89 authored
Showing with 35 additions and 11 deletions.
  1. +1 −1  package.json
  2. +34 −10 zerver.js
View
2  package.json
@@ -2,7 +2,7 @@
"author": "Jairaj Sethi <j@jairaj.org> (http://jairaj.org/)",
"name": "zerver",
"description": "client-integrated webapp server",
- "version": "0.6.3",
+ "version": "0.6.4",
"repository": {
"type": "git",
"url": "git://github.com/jairajs89/zerver.git"
View
44 zerver.js
@@ -116,6 +116,16 @@ function configureZerver (port, apiDir, apiURL, debug, refresh, manifests, produ
startTimestamp = new Date();
+ if (DEBUG) {
+ CACHE_CONTROL = 'no-cache';
+ }
+ else if (HAS_MANIFEST) {
+ CACHE_CONTROL = 'max-age=0';
+ }
+ else {
+ CACHE_CONTROL = 'max-age=14400';
+ }
+
if (manifests) {
manifests.split(',').forEach(function (path) {
if (!path[0] !== '/') {
@@ -124,17 +134,9 @@ function configureZerver (port, apiDir, apiURL, debug, refresh, manifests, produ
MANIFESTS[path] = true;
HAS_MANIFEST = true;
- });
- }
- if (DEBUG) {
- CACHE_CONTROL = 'no-cache';
- }
- else if (HAS_MANIFEST) {
- CACHE_CONTROL = 'max-age=0';
- }
- else {
- CACHE_CONTROL = 'max-age=14400';
+ prefetchManifestFile(path);
+ });
}
fetchAPIs();
@@ -162,6 +164,28 @@ function relativePath (path1, path2) {
}
}
+function prefetchManifestFile (pathname, callback) {
+ var fileName = path.join(ROOT_DIR, pathname);
+
+ fs.stat(fileName, function (err, stats) {
+ if (err || !stats.isFile()) {
+ return;
+ }
+
+ fs.readFile(fileName, 'utf8', function (err, data) {
+ if (err || !data) {
+ return;
+ }
+
+ prepareManifestConcatFiles(data, pathname, function () {
+ if (callback) {
+ callback();
+ }
+ });
+ });
+ });
+}
+
function handleRequest (request, response) {
var urlParts = url.parse(request.url),
handler = {
Please sign in to comment.
Something went wrong with that request. Please try again.