Last active
January 21, 2020 22:50
-
-
Save leodutra/f417cdfd9aaf361e3c6b to your computer and use it in GitHub Desktop.
Cache - Control, Pragma, Expires, must-revalidate, no-store, no-cache Stuff (force)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%-- https://www.mnot.net/cache_docs/ --%> | |
<%-- http://www.mobify.com/blog/beginners-guide-to-http-cache-headers/ --%> | |
<%-- http://stackoverflow.com/a/18516720/1260526 --%> | |
<%-- https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching --%> | |
<%-- http://stackoverflow.com/questions/18148884/difference-between-no-cache-and-must-revalidate --%> | |
<%-- http://stackoverflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers --%> | |
<meta http-equiv="Cache-Control" content="no-store, must-revalidate" /> | |
<%--OPTIONS most badly, see http://stackoverflow.com/a/18516720/1260526 | |
no-cache, no-store, must-revalidate, proxy-revalidate, max-age=0, s-max-age=0 | |
--%> | |
<%--meta http-equiv="Pragma" content="no-cache" (bad, see: http://stackoverflow.com/a/18516720/1260526) --%> | |
<%--meta http-equiv="Expires" content="0" (bad, see: http://stackoverflow.com/a/18516720/1260526) --%> | |
<% | |
//response.setDateHeader ("Expires", 0); (bad, see: http://stackoverflow.com/a/18516720/1260526) | |
//response.setHeader("Pragma","no-cache"); (bad, see: http://stackoverflow.com/a/18516720/1260526) | |
if (request.getProtocol().equals("HTTP/1.1")){ | |
response.setHeader("Cache-Control","no-store, must-revalidate"); | |
} | |
else { | |
response.setHeader("Pragma","no-cache"); | |
response.setDateHeader ("Expires", -1); | |
%> | |
<meta http-equiv="pragma" content="no-cache" /> | |
<meta http-equiv="expires" content="-1" /> | |
<% | |
} | |
%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment