2
0
Эх сурвалжийг харах

Improved caching and improved production scripts.

KrisVos130 7 жил өмнө
parent
commit
0c40028e9f

+ 6 - 2
backend/index.js

@@ -210,7 +210,8 @@ function initialize() {
 
 				app.get("/locales/*", (req, res) => {
 					let path = req.path;
-					console.log(rootDirLocales, path, rootDirLocales + path);
+					res.set('Cache-Control', 'max-age=8640000000');
+
 					fs.access(rootDirLocales + path, function (err) {
 						console.log("Error: ", !!err);
 						if (!err) {
@@ -223,7 +224,8 @@ function initialize() {
 
 				app.get("/assets/*", (req, res) => {
 					const path = req.path;
-					console.log(rootDirAssets, path, rootDirAssets + path);
+					res.set('Cache-Control', 'max-age=8640000000');
+
 					fs.access(rootDirAssets + path, function (err) {
 						console.log("Error: ", !!err);
 						if (!err) {
@@ -236,8 +238,10 @@ function initialize() {
 
 				app.get("/*", (req, res) => {
 					const path = req.path;
+
 					fs.access(rootDir + path, function (err) {
 						if (!err) {
+							res.set('Cache-Control', 'max-age=8640000000');
 							res.sendFile(rootDir + path);
 						} else {
 							res.sendFile(rootDir + "index.html");

+ 1 - 1
frontend/app/index.tpl.html

@@ -39,7 +39,7 @@
 		  type="text/css">
 	<link href="https://fonts.googleapis.com/css?family=Roboto:100,400" rel="stylesheet">
 	<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
-	<script src="https://www.youtube.com/iframe_api"></script>
+	<!--script src="https://www.youtube.com/iframe_api"></script-->
 	<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.0/moment.min.js"></script>
 	<script type="text/javascript"
 			src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.8/socket.io.min.js"></script>

+ 2 - 1
frontend/package.json

@@ -7,7 +7,8 @@
   "repository": "https://github.com/Musare/MusareNode",
   "scripts": {
     "dev": "webpack --watch",
-    "production": "SET NODE_ENV=production&& webpack",
+    "production-windows": "NODE_ENV=production&& webpack",
+    "production-linux": "export NODE_ENV=production&& webpack",
     "lint": "eslint ./app/js ./webpack.config.js -f table --ext .js --ext .jsx || true"
   },
   "devDependencies": {