[DEV] better cache management
This commit is contained in:
parent
e421ead4ab
commit
a4f6dd5756
@ -25,6 +25,9 @@ public class Front {
|
|||||||
String extention = getExtension(filePathName);
|
String extention = getExtension(filePathName);
|
||||||
String mineType = null;
|
String mineType = null;
|
||||||
System.out.println("try retrive : '" + filePathName + "' '" + extention + "'");
|
System.out.println("try retrive : '" + filePathName + "' '" + extention + "'");
|
||||||
|
CacheControl cc = new CacheControl();
|
||||||
|
cc.setMaxAge(3600);
|
||||||
|
cc.setNoCache(false);
|
||||||
if (extention.length() !=0 && extention.length() <= 5) {
|
if (extention.length() !=0 && extention.length() <= 5) {
|
||||||
if (extention.equalsIgnoreCase("jpg") || extention.equalsIgnoreCase("jpeg")) {
|
if (extention.equalsIgnoreCase("jpg") || extention.equalsIgnoreCase("jpeg")) {
|
||||||
mineType = "image/jpeg";
|
mineType = "image/jpeg";
|
||||||
@ -37,15 +40,23 @@ public class Front {
|
|||||||
} else if (extention.equalsIgnoreCase("webp")) {
|
} else if (extention.equalsIgnoreCase("webp")) {
|
||||||
mineType = "image/webp";
|
mineType = "image/webp";
|
||||||
} else if (extention.equalsIgnoreCase("js")) {
|
} else if (extention.equalsIgnoreCase("js")) {
|
||||||
|
cc.setMaxAge(1);
|
||||||
|
cc.setNoCache(true);
|
||||||
mineType = "application/javascript";
|
mineType = "application/javascript";
|
||||||
} else if (extention.equalsIgnoreCase("json")) {
|
} else if (extention.equalsIgnoreCase("json")) {
|
||||||
mineType = "application/json";
|
mineType = "application/json";
|
||||||
|
cc.setMaxAge(1);
|
||||||
|
cc.setNoCache(true);
|
||||||
} else if (extention.equalsIgnoreCase("ico")) {
|
} else if (extention.equalsIgnoreCase("ico")) {
|
||||||
mineType = "image/x-icon";
|
mineType = "image/x-icon";
|
||||||
} else if (extention.equalsIgnoreCase("html")) {
|
} else if (extention.equalsIgnoreCase("html")) {
|
||||||
mineType = "text/html";
|
mineType = "text/html";
|
||||||
|
cc.setMaxAge(1);
|
||||||
|
cc.setNoCache(true);
|
||||||
} else if (extention.equalsIgnoreCase("css")) {
|
} else if (extention.equalsIgnoreCase("css")) {
|
||||||
mineType = "text/css";
|
mineType = "text/css";
|
||||||
|
cc.setMaxAge(1);
|
||||||
|
cc.setNoCache(true);
|
||||||
} else {
|
} else {
|
||||||
return Response.status(403).
|
return Response.status(403).
|
||||||
entity("Not supported model: '" + fileName + "'").
|
entity("Not supported model: '" + fileName + "'").
|
||||||
@ -68,9 +79,6 @@ public class Front {
|
|||||||
ResponseBuilder response = Response.ok((Object)download);
|
ResponseBuilder response = Response.ok((Object)download);
|
||||||
// use this if I want to download the file:
|
// use this if I want to download the file:
|
||||||
//response.header("Content-Disposition", "attachment; filename=" + fileName);
|
//response.header("Content-Disposition", "attachment; filename=" + fileName);
|
||||||
CacheControl cc = new CacheControl();
|
|
||||||
cc.setMaxAge(60);
|
|
||||||
cc.setNoCache(false);
|
|
||||||
response.cacheControl(cc);
|
response.cacheControl(cc);
|
||||||
response.type(mineType);
|
response.type(mineType);
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
|
||||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||||
|
|
||||||
export const environment = {
|
const environment_local = {
|
||||||
production: false,
|
production: false,
|
||||||
// URL of development API
|
// URL of development API
|
||||||
applName: "karideo",
|
applName: "karideo",
|
||||||
@ -19,7 +19,7 @@ export const environment = {
|
|||||||
apiMode: 'REWRITE'
|
apiMode: 'REWRITE'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const environment_kjlkjlkjlkj = {
|
const environment_hybrid = {
|
||||||
production: false,
|
production: false,
|
||||||
// URL of development API
|
// URL of development API
|
||||||
applName: "karideo",
|
applName: "karideo",
|
||||||
@ -28,9 +28,12 @@ export const environment_kjlkjlkjlkj = {
|
|||||||
karideo: 'http://192.168.1.156/karideo/api',
|
karideo: 'http://192.168.1.156/karideo/api',
|
||||||
karauth: 'http://192.168.1.156/karauth/api',
|
karauth: 'http://192.168.1.156/karauth/api',
|
||||||
},
|
},
|
||||||
ssoSignIn: 'http://localhost:4200/signin/karideo-dev/',
|
ssoSignIn: 'http://192.168.1.156/karso/signin/karideo-dev/',
|
||||||
ssoSignUp: 'http://localhost:4200/signup/karideo-dev/',
|
ssoSignUp: 'http://192.168.1.156/karso/signup/karideo-dev/',
|
||||||
ssoSignOut: 'http://localhost:4200/signout/karideo-dev/',
|
ssoSignOut: 'http://192.168.1.156/karso/signout/karideo-dev/',
|
||||||
frontBaseUrl: '',
|
frontBaseUrl: '',
|
||||||
apiMode: 'REWRITE'
|
apiMode: 'REWRITE'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export const environment = environment_hybrid;
|
Loading…
x
Reference in New Issue
Block a user