In the "Expires" header, the date format does not comply with RFC1123. In fact, correct line should be : new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US)
I think it should be:
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US)
moreover, the date formatter should be a static property to speed the request a little bit:
private static final DateFormat dateFormatter = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss zzz", Locale.ROOT); static { dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT")); }
public static void setCacheHeader(HttpServletResponse response, long expirationTime) { response.setHeader("Pragma", ""); response.setHeader("Cache-Control", "public"); Date expirationDate = new Date(System.currentTimeMillis() + expirationTime); response.setHeader("Expires", dateFormatter.format(expirationDate)); }
Log in to post a comment.
I think it should be:
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US)
moreover, the date formatter should be a static property to speed the request a little bit:
private static final DateFormat dateFormatter = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss zzz", Locale.ROOT);
static {
dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT"));
}
public static void setCacheHeader(HttpServletResponse response, long expirationTime) {
response.setHeader("Pragma", "");
response.setHeader("Cache-Control", "public");
Date expirationDate = new Date(System.currentTimeMillis() + expirationTime);
response.setHeader("Expires", dateFormatter.format(expirationDate));
}