Browse Source

Fixed the server from not serving txt files for sitemap.txt and robots.txt

pull/4/head
jrtechs 6 years ago
parent
commit
ec91c40b81
2 changed files with 8 additions and 7 deletions
  1. +6
    -5
      includes/includes.js
  2. +2
    -2
      server.js

+ 6
- 5
includes/includes.js View File

@ -55,9 +55,7 @@ module.exports =
*/ */
sendCSS: function(result, path, cache) sendCSS: function(result, path, cache)
{ {
var css = cache.get(path);
const css = cache.get(path);
if(css == null) if(css == null)
{ {
@ -77,8 +75,11 @@ module.exports =
} }
else else
{ {
var eTag = crypto.createHash('md5').update(css).digest('hex');
result.writeHead(200, {'Content-Type': 'text/css', 'Cache-Control': 'public, max-age=2678400', 'ETag': '"' + eTag + '"', 'Vary': 'Accept-Encoding'});
const eTag = crypto.createHash('md5').update(css).digest('hex');
result.writeHead(200, {'Content-Type': 'text/css',
'Cache-Control': 'public, max-age=2678400',
'ETag': '"' + eTag + '"',
'Vary': 'Accept-Encoding'});
result.write(css); result.write(css);
result.end(); result.end();
} }

+ 2
- 2
server.js View File

@ -27,7 +27,7 @@ const app = express();
//compresses the site //compresses the site
var compression = require('compression')
const compression = require('compression')
app.use(compression()); app.use(compression());
const port = 8000; const port = 8000;
@ -50,7 +50,7 @@ app.use(function(request, res)
{ {
require("./img/image.js").main(res, filename, cache); require("./img/image.js").main(res, filename, cache);
} }
else if(filename.includes("/css/") || filename.includes(".woff2"))
else if(filename.includes("/css/") || filename.includes(".woff2") || filename.includes(".txt"))
{ {
includes.sendCSS(res, filename, cache) includes.sendCSS(res, filename, cache)
} }

Loading…
Cancel
Save