Our client uses IE8, and its caching-hungry ways makes things difficult. To fix this I added a bean to prevent caching
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="cacheSeconds" value="0" />
</bean>
According to Chrome's (Very useful) developer tool, I can see that Response Headers are:
Cache-Control:no-cache
Cache-Control:no-store
Content-Length:1070
Content-Type:text/html;charset=utf-8
Date:Tue, 27 Nov 2012 17:21:31 GMT
Expires:Thu, 01 Jan 1970 00:00:00 GMT
Pragma:no-cache
However, now I'm getting a 406 response. Why would I be getting this?
The Request Headers are:
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:redacted
Host:localhost:8040
Referer:http://localhost:8040/redacted
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11
X-Requested-With:XMLHttpRequest
I took a look at this answer, but I'm already using Jackson.
Found the answer. Once again it's a problem with how the beans are ordered. If I place the no-cache bean AFTER the jackson bean, then it works.
Related
I've been testing Cloudflare, and I have Edge TTL set for 1 month for everything in the images folder. I'd like to see if this is set correctly, but in the Response Headers I don't see an EDGE TTL expiry. Is there any way for me to see when the cache will expire for an object in Cloudflare?
Here's the sample headers:
Response Headers
Request URL:https://cdn.mysite.com/content/testimage.jpg
Request Method:GET
Status Code:200
Remote Address:104.27.138.237:443
Referrer Policy:no-referrer-when-downgrade
Response Headers
accept-ranges:bytes
cache-control:public, max-age=14400
cf-cache-status:HIT
cf-ray:37fa88117ff010f3-ORD
content-length:10512
content-type:image/jpeg
date:Mon, 17 Jul 2017 04:41:54 GMT
etag:"b9a9dca80fa816483b4df7e970639c98"
expires:Mon, 17 Jul 2017 08:41:54 GMT
last-modified:Mon, 17 Jul 2017 04:13:53 GMT
server:cloudflare-nginx
status:200
vary:Accept-Encoding
via:1.1 d784ab98a21beb476de2ec8d5824cf82.cloudfront.net (CloudFront)
x-amz-cf-id:MhQHg0-wZ_l7yEPeFkOvt7JXn4xuicRBpIVw2jlcy6Lt9KvukCrFcw==
x-amz-meta-s3cmd-attrs:atime:1499536352/ctime:1499536352/gid:1000/gname:sluser/mode:33204/mtime:1499536352/uid:1000/uname:sluser
x-cache:Miss from cloudfront
Request Headers
:authority:cdn.mysite.com
:method:GET
:path:/content/testimage.jpg
:scheme:https
accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
accept-encoding:gzip, deflate, br
accept-language:en-US,en;q=0.8
cache-control:no-cache
cookie:__cfduid=df4ff5a2242e05fbc12499e832333f59c1500222401
pragma:no-cache
upgrade-insecure-requests:1
user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
Because EDGE TTL expiry are not reflected in the response header. They use this for their internal parameter to store files.
Visit this link for more detail
https://support.cloudflare.com/hc/en-us/articles/200168376-What-does-edge-cache-expire-TTL-mean-
Hi I am developing services in web api2 vs2015. Initially i had cors issue i fixed and http verbs like get,delete,put,post working fine in mozilla and internet explorer. I am getting errors in google chrome for put and delete request. I am not able to do put and delete in google chrome. This is my request and response values in chrome.
Request URL:http://192.168.0.213:8041/User_Creation/1019
Request Method:OPTIONS
Status Code:400 Bad Request
Remote Address:192.168.0.213:8041
**Response Headers**
view source
Cache-Control:no-cache
Content-Length:58
Content-Type:application/json; charset=utf-8
Date:Mon, 16 Jan 2017 10:07:04 GMT
Expires:-1
Pragma:no-cache
Server:Microsoft-IIS/8.5
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET
**Request Headers**
view source
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
Access-Control-Request-Headers:
Access-Control-Request-Method:DELETE
Connection:keep-alive
Host:192.168.0.213:8041
Origin:http://192.168.0.213:8040
Referer:http://192.168.0.213:8040/usercreation/Index
User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
I have below line of code in web.config
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Methods" value="POST, PUT, DELETE, GET, OPTIONS" />
<add name="Access-Control-Allow-Headers" value="content-Type, accept, origin, X-Requested-With, Authorization, name" />
<add name="Access-Control-Allow-Credentials" value="true" />
</customHeaders>
</httpProtocol>
Am i missing anything here?
I am sending requesting delete http verb and in 3rd line i can see options verb. I am confused here. May i know how can i fix this issue? Thank you for your help.
I am trying to speed up some ajax calls by facilitating ETags. What I've got at the moment works sometimes (ajax calls that are 304 not modified take 40ms instead of 100ms).
However, what I am noticing is, that chrome apparently only sends the If-None-Match header just for one request but doees never send it on Windows machines. This is quite a pity, as the resource this is about I am loading quite frequently to check for changes. Having ETags work all the time would be really helpful in that case.
Here's what is happening on the wire:
GET /api/book/all/READ HTTP/1.1
Host: something
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36
Accept: */*
Referer: http://something/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: de,en-US;q=0.8,en;q=0.6
Cookie: PHPSESSID=something
and the response:
HTTP/1.1 200 OK
Date: Mon, 04 Apr 2016 06:00:17 GMT
Server: Apache
Expires: Thu, 19 Nov 1981 08:52:00 GMT
ETag: "1"
Cache-Control: "max-age=0, must-revalidate"
Vary: Accept-Encoding
Content-Encoding: gzip
Keep-Alive: timeout=2, max=995
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/json;charset=utf8
(as a side note, the ETag value I use refers to the version of the data - each time the data is modified, the version is incremented)
In the next request, on Mac, Chrome will send the appropriate If-None-Match header, and the API will respond with a 304 not modified. However, the second time that resource is being loaded, there will not be any If-None-Match header again.
On Windows, Chrome will just not send the If-None-Match header and therefore the server will respond with the full payload.
The way I would like to have it, is that the browser would always send the If-None-Match header, so that the backend can do a proper job to decide if the cached API response is still fresh.
on mac, this is how the second request (where the If-None-Match header is sent) looks:
GET /api/book/all/READ HTTP/1.1
Host: something
Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36
Accept: */*
Referer: http://something/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: de,en-US;q=0.8,en;q=0.6
Cookie: PHPSESSID=something
If-None-Match: "1"
and the response:
HTTP/1.1 304 Not Modified
Date: Mon, 04 Apr 2016 05:27:19 GMT
Server: Apache
Connection: Keep-Alive
Keep-Alive: timeout=2, max=1000
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Vary: Accept-Encoding
I have a SPA (Single-Page Application) written using OpenUI5 framework.
It works well (when I'm in debug mode or using cache-killer https://chrome.google.com/webstore/detail/cache-killer/jpfbieopdmepaolggioebjmedmclkbap) but now I have pushed the app on the server apache: here the problems started...
Users not have cache-killer installed and I would like update the app on the server and immediately have the new version of the app on the users pcs at the successive refresh.
In my app I have a series of tab: each tab have a content and I have two different content for each tab (a display fragment content and a change fragment content).
When I load the page, by default, tabs are filled by display fragments; then I press a button and the content of each tab swithc to the change fragments.
The problem is that all fragment that I retrieve after the first page loading are loaded (from cache)...
I try to use manifest application cache and the various meta-tags (see Chaching with single-page application) but the problem not change and it is still there.
This is a request-response header for the diplay fragment (correcly loaded from the server)
General:
Request URL:http://10.7.1.96/www/temp_ftp_grunt/view/tab/article/TabAnagrDisplay.fragment.xml
Request Method:GET
Status Code:304 Not Modified
Response header:
HTTP/1.1 304 Not Modified
Date: Thu, 17 Sep 2015 14:45:43 GMT
Server: Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.6
Connection: Keep-Alive
Keep-Alive: timeout=5, max=46
ETag: "38b6-51ff07d7bfe81"
Request Header:
GET /www/temp_ftp_grunt/view/tab/article/TabAnagrDisplay.fragment.xml HTTP/1.1
Host: 10.7.1.96
Connection: keep-alive
Cache-Control: max-age=0
Accept: application/xml, text/xml, */*; q=0.01
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36
Referer: http://10.7.1.96/www/temp_ftp_grunt/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: it,en-US;q=0.8,en;q=0.6
If-None-Match: "38b6-51ff07d7bfe81"
If-Modified-Since: Thu, 17 Sep 2015 12:24:01 GMT
and this for the change fragment loaded from cache
General:
Request URL:http://10.7.1.96/www/temp_ftp_grunt/view/tab/article/TabAnagrChange.fragment.xml
Request Method:GET
Status Code:200 OK (from cache)
Response header:
Accept-Ranges:bytes
Content-Length:23642
Content-Type:application/xml
Date:Thu, 17 Sep 2015 14:44:47 GMT
ETag:"5c5a-51ff1965857b1"
Last-Modified:Thu, 17 Sep 2015 13:42:33 GMT
Server:Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.6"
Request Header:
Provisional headers are shown
Accept:application/xml, text/xml, */*; q=0.01
Referer:http://10.7.1.96/www/temp_ftp_grunt/
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36
X-Requested-With:XMLHttpRequest
For OpenUI5 developers: I have loaded the fragment in this moode:
1.display fragments in onInit function of the controller that contain the list of tabs
var oTab = new sap.m.IconTabFilter();
oTab.addContent(myfragment);
tabBar.addItem(oTab);
2.change fragments by a function that remove the display frg by tabBar.removeAllItems(); and add the new frg in the same mode of 1.
I have tried to find a solution to my problem; I have read this https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching and this http://alistapart.com/article/application-cache-is-a-douchebag articles but I can't find the solution for my problem. Cache buster https://openui5.hana.ondemand.com/#docs/guide/91f080966f4d1014b6dd926db0e91070.html suggested here Force clear cache in OpenUI5 require a SAP backend
We had the same problem and managed by defining a new path for fragments
sap.ui.localResources("fragments");
By default, fragments was in the same folder than Libraries (resources) and always caching.
I have a Cloudfront distribution that points to a server that resizes images from an S3 bucket. The server returns a Cache-Control header with public, max-age=31104000, but I keep getting
miss from Cloudfront so the images are not cached in Cloudfront.
To test, I set up another Cloudfront distribution that points directly to the S3 bucket, and that indeed caches the images with hit from Cloudfront.
I compared the request and response headers, and the only difference is that the miss has a Last-Modified header response, which is missing from the good request. However, I'm not sure that's the problem.
Do you have any idea of what is happening? Here are the headers:
Good Response:
Age:10
Cache-Control:public, max-age=31104000
Connection:keep-alive
Date:Sat, 05 Sep 2015 16:15:51 GMT
ETag:"51dbe11a5fa320c4495221b69df1d860"
Server:AmazonS3
Via:1.1 b7bc8b4c398aa9f5a08980055c497334.cloudfront.net (CloudFront)
X-Amz-Cf-Id:4KE-cAoFrTmcjkRW3goZAImvyQE5i1Vl4KZyrWL8HyCk6GcJZ9N7Kw==
X-Cache:Hit from cloudfront
Bad Response:
Cache-Control:public, max-age=31104000
Connection:keep-alive
Date:Sat, 05 Sep 2015 16:16:42 GMT
ETag:"51dbe11a5fa320c4495221b69df1d860"
Last-Modified:Sat, 05 Sep 2015 16:07:41 GMT
Server:nginx/1.6.2
Via:1.1 45578d14a69df96accaab0d1aba82a5a.cloudfront.net (CloudFront)
X-Amz-Cf-Id:FGMRwDI0vOJQ7aPj83s-RGTO0fg_Zesu7FLo7Ia5vwCxcTZI97ri5A==
X-Cache:Miss from cloudfront
Good Request:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0 .8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8,da;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
Host:assets.runemadsen.com
If-Modified-Since:Sat, 05 Sep 2015 16:07:41 GMT
If-None-Match:"51dbe11a5fa320c4495221b69df1d860"
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 ( KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36
Bad Request:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0 .8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8,da;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
Host:images.runemadsen.com
If-Modified-Since:Sat, 05 Sep 2015 16:07:41 GMT
If-None-Match:"51dbe11a5fa320c4495221b69df1d860"
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 ( KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36
Any help appreciated.
Thanks for the comments. Here's the final update: The reason was that an older response without the Cache-Control was cached in Cloudfront, which somehow made cloudfront continously reload the image from the origin. I'm not sure exactly how a cached response can trigger constant "miss", but that's what happened. I invalidated the route, and Cloudfront started cahing the images.