Does anyone know if there is something strange going on? It seems that my reverse proxy setup, doesn't preserve the correct caching headers from the original virtualhost.
Let me explain...
I am currently using PHP Slim to create an API for my web app. It has its own caching mechanisms, which are setup and running fine. So, when visiting the resource api.example.com/info
for example, I have a Last-Modified that is set, which allows it to be cached (it doesn't change very often).
As such, the headers looks something like:
Request URL:http://api.example.com/info Request Method:GET Status Code:304 Not Modified
Request Headers
Accept:text/html,application/xhtml xml,application/xml;q=0.9,*/*;q=0.8 Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3 Accept-Encoding:gzip,deflate,sdch Accept-Language:en-GB,en-US;q=0.8,en;q=0.6 Cache-Control:max-age=0 Connection:keep-alive Host:api.example.com If-Modified-Since:Mon, 04 Oct 2010 08:00:52 1100 User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
Response Headers
Connection:Keep-Alive Date:Tue, 19 Jun 2012 22:34:45 GMT Keep-Alive:timeout=5, max=100 Server:Apache/2.2.21 (Win64) PHP/5.3.8 Vary:Accept-Encoding
Which shows that the resource returns with a 304 - it's been retrieved from cache. Great!
However, the web app accesses this from a reverse proxy (cross domain issues). When accessing the exact same resource, this time from app.example.com/api/info
, it returns with a 200 code. Its also noteably slower to load, which makes me think something isn't working.
This time, the headers are
Request URL:http://app.example.com/api/info Request Method:GET Status Code:200 OK
Request Headers
Accept:text/html,application/xhtml xml,application/xml;q=0.9,*/*;q=0.8 Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3 Accept-Encoding:gzip,deflate,sdch Accept-Language:en-GB,en-US;q=0.8,en;q=0.6 Cache-Control:max-age=0 Connection:keep-alive Host:app.example.com If-Modified-Since:Mon, 04 Oct 2010 08:00:52 GMT User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
Response Headers
Connection:Keep-Alive Content-Encoding:gzip Content-Length:1959 Content-Type:application/json Date:Tue, 19 Jun 2012 22:41:01 GMT Keep-Alive:timeout=5, max=100 Last-Modified:Mon, 04 Oct 2010 08:00:52 GMT Server:Apache/2.2.21 (Win64) PHP/5.3.8 Vary:Accept-Encoding X-API-Version:v1.0 X-Powered-By:PHP/5.3.8, Slim
Any ideas? Sorry about the mass of header info above - didn't want to leave out any information.
If-Modified-Since
header is right? One or the other has a borked time zone.If-Modified-Since:Mon, 04 Oct 2010 08:00:52 +1100
is the correct one (AEST). Would that make a difference?