Browse Source

Prevented server from caching admin page and started self hosting the font file.

pull/4/head
jrtechs 6 years ago
parent
commit
0014135788
5 changed files with 25 additions and 7 deletions
  1. +1
    -0
      admin/admin.js
  2. +2
    -1
      css/minified.css
  3. BIN
      css/openSans.woff2
  4. +2
    -2
      js/js.js
  5. +20
    -4
      server.js

+ 1
- 0
admin/admin.js View File

@ -34,6 +34,7 @@ module.exports=
else
{
//login page
console.log("login page");
require("../admin/login.js").main(request).then(function(html)
{
resolve(html);

+ 2
- 1
css/minified.css
File diff suppressed because it is too large
View File


BIN
css/openSans.woff2 View File


+ 2
- 2
js/js.js View File

@ -18,7 +18,7 @@ module.exports=
utils.include("." + fileName).then(function(content)
{
var eTag = crypto.createHash('md5').update(content).digest('hex');
result.writeHead(200, {'Content-Type': 'application/javascript', 'Cache-Control': 'public, max-age=2678400', 'ETag': '"' + eTag + '"'});
result.writeHead(200, {'Content-Type': 'application/javascript', 'Cache-Control': 'public, max-age=2678400', 'ETag': '"' + eTag + '"', 'Vary': 'Accept-Encoding'});
result.write(content);
result.end();
cache.put(content);
@ -27,7 +27,7 @@ module.exports=
else
{
var eTag = crypto.createHash('md5').update(js).digest('hex');
result.writeHead(200, {'Content-Type': 'application/javascript', 'Cache-Control': 'public, max-age=2678400', 'ETag': '"' + eTag + '"'});
result.writeHead(200, {'Content-Type': 'application/javascript', 'Cache-Control': 'public, max-age=2678400', 'ETag': '"' + eTag + '"', 'Vary': 'Accept-Encoding'});
result.write(js);
result.end();
}

+ 20
- 4
server.js View File

@ -44,7 +44,7 @@ app.use(function(request, res)
{
require("./img/image.js").main(res, filename, cache);
}
else if(filename.includes("/css/") || filename.includes(".txt"))
else if(filename.includes("/css/") || filename.includes(".woff2"))
{
includes.sendCSS(res, filename, cache)
}
@ -56,6 +56,25 @@ app.use(function(request, res)
{
require("./downloads/downloads.js").main(res, filename, request);
}
else if(filename.includes("/admin"))
{
res.writeHead(200, {'Content-Type': 'text/html'});
file = "./admin/admin.js";
Promise.all([includes.printHeader(),
require(file).main(filename, request),
includes.printFooter()]).then(function(content)
{
res.write(content.join(''));
res.end();
}).catch(function(err)
{
console.log(err);
throw err;
});
}
else
{
var file = "";
@ -76,9 +95,6 @@ app.use(function(request, res)
if(urlSplit.length >= 2 && urlSplit[1] === 'category') //single category page
file = "./posts/category.js";
else if(urlSplit.length >= 2 && urlSplit[1] === 'admin') //top secret admin page
file = "./admin/admin.js";
else
file = "./posts/posts.js";
}

Loading…
Cancel
Save