Browse Source

better caching, minimized jquery

master
mort 8 years ago
parent
commit
4691f01e2b
5 changed files with 10 additions and 3 deletions
  1. 2
    1
      conf.json.example
  2. 2
    1
      server.js
  3. 1
    1
      templates/head.html
  4. 5
    0
      web/i/index.node.js
  5. 0
    0
      web/view/script.js

+ 2
- 1
conf.json.example View File

@@ -26,7 +26,8 @@
},
"debug": false,
"max_runs": 9999,
"cache_max_age": 604800,
"cache_max_age": 2628000,
"cache_max_age_images": 2628000,
"purge_collections_timeout": "2 days",
"purge_collections_interval": 1800000
}

+ 2
- 1
server.js View File

@@ -40,6 +40,7 @@ var endpoints = {
//Viewer
"/view": "view/index.node.js",
"/view/style.css": "view/style.css",
"/view/script.js": "view/script.js",

//Plain images
"/i": "i/index.node.js",
@@ -92,7 +93,7 @@ function onRequest(req, res) {
var ep = loaded.endpoints[req.url.split("?")[0]];

//If the file doesn't exist, we 404.
if (!ep) {
if (ep === undefined) {
ep = loaded.endpoints["/404"];
ctx.setStatus(404);
}

+ 1
- 1
templates/head.html View File

@@ -6,7 +6,7 @@
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="/{{env#view}}/style.css?{{conf#currentRun}}">

<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="/global.js?{{conf#currentRun}}"></script>
<script src="/{{env#view}}/script.js?{{conf#currentRun}}"></script>

+ 5
- 0
web/i/index.node.js View File

@@ -5,6 +5,11 @@ module.exports = function(ctx) {
if (!id)
return ctx.end(ctx.view("404"));

ctx.res.setHeader(
"Cache-Control",
"public, max-age="+ctx.conf.cache_max_age_images
);

var readStream = fs.createReadStream(ctx.conf.dir.imgs+"/"+id);
readStream.pipe(ctx.res);


+ 0
- 0
web/view/script.js View File


Loading…
Cancel
Save