Apache 2.4发送旧页面

时间:2014-04-30 21:37:45

标签: apache caching etag last-modified

我有一个apache 2.4服务器,它提供一个名为resource.js的文件。

当我请求资源时,它返回一个旧页面。我的浏览器不会在请求中发送ETAG或Last-Modified标头,可能是因为它没有缓存此资源。 这是发生这种情况时HAR的片段

      {
    "startedDateTime": "2014-04-30T21:01:36.384Z",
    "time": 0,
    "request": {
      "method": "GET",
      "url": "https://someserver/resource.js",
      "headers": [
        {
          "name": "User-Agent",
          "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36"
        }
      ],
      "queryString": [],
      "cookies": [],
      "headersSize": -1,
      "bodySize": 0
    },
    "response": {
      "status": 200,
      "statusText": "OK",
      "httpVersion": "HTTP/1.1",
      "headers": [
        {
          "name": "Date",
          "value": "Wed, 30 Apr 2014 20:46:57 GMT"
        },
        {
          "name": "Last-Modified",
          "value": "Thu, 24 Apr 2014 23:42:51 GMT"
        },
        {
          "name": "Server",
          "value": "Apache/2.4.4 (Unix) OpenSSL/1.0.1 PHP/5.4.12"
        },
        {
          "name": "ETag",
          "value": "\"e00-4f7d2684c7fb9\""
        },
        {
          "name": "Content-Type",
          "value": "application/javascript"
        },
        {
          "name": "Connection",
          "value": "Keep-Alive"
        },
        {
          "name": "Accept-Ranges",
          "value": "bytes"
        },
        {
          "name": "Keep-Alive",
          "value": "timeout=5, max=98"
        },
        {
          "name": "Content-Length",
          "value": "3584"
        }
      ],
      "cookies": [],
      "content": {
        "size": 3584,
        "mimeType": "application/javascript",
        "text": "...."
      },
      "redirectURL": "",
      "headersSize": 318,
      "bodySize": 0
    },
    "cache": {},
    "timings": {
      "blocked": -1,
      "dns": -1,
      "connect": -1,
      "send": 0,
      "wait": 0,
      "receive": 0,
      "ssl": -1
    },
    "connection": "48540",
    "pageref": "page_1"
  },

我知道这是一个旧页面,因为我可以验证页面的内容不是服务器上的内容。另请注意,当我今天修改此文件时,响应会返回一个ETAG(这是错误的)和一个7天前的Last-Modified日期。

在后续请求中,在作为请求的一部分提交ETAG和Last-Modified标头之后,apache服务器返回正确的页面:

      {
    "startedDateTime": "2014-04-30T21:03:02.771Z",
    "time": 490.7269477844238,
    "request": {
      "method": "GET",
      "url": "https://someserver/resource.js",
      "httpVersion": "HTTP/1.1",
      "headers": [
        {
          "name": "Cookie",
          "value": "__utma=37592696.1580400495.1393617937.1393617937.1394060568.2; __utmz=37592696.1393617937.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); m=1933:60%7C5|2491:chart|34e2:|4e71:small"
        },
        {
          "name": "Accept-Encoding",
          "value": "gzip,deflate,sdch"
        },
        {
          "name": "Host",
          "value": "someserver"
        },
        {
          "name": "Accept-Language",
          "value": "en-US,en;q=0.8"
        },
        {
          "name": "User-Agent",
          "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36"
        },
        {
          "name": "Accept",
          "value": "*/*"
        },
        {
          "name": "Cache-Control",
          "value": "max-age=0"
        },
        {
          "name": "If-None-Match",
          "value": "\"e00-4f7d2684c7fb9\""
        },
        {
          "name": "Connection",
          "value": "keep-alive"
        },
        {
          "name": "If-Modified-Since",
          "value": "Thu, 24 Apr 2014 23:42:51 GMT"
        },
        {
          "name": "Referer",
          "value": "https://someserver"
        }
      ],
      "queryString": [],
      "cookies": [
        {
          "name": "__utma",
          "value": "37592696.1580400495.1393617937.1393617937.1394060568.2",
          "expires": null,
          "httpOnly": false,
          "secure": false
        },
        {
          "name": "__utmz",
          "value": "37592696.1393617937.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)",
          "expires": null,
          "httpOnly": false,
          "secure": false
        },
        {
          "name": "m",
          "value": "1933:60%7C5|2491:chart|34e2:|4e71:small",
          "expires": null,
          "httpOnly": false,
          "secure": false
        }
      ],
      "headersSize": 667,
      "bodySize": 0
    },
    "response": {
      "status": 200,
      "statusText": "OK",
      "httpVersion": "HTTP/1.1",
      "headers": [
        {
          "name": "Date",
          "value": "Wed, 30 Apr 2014 21:03:03 GMT"
        },
        {
          "name": "Last-Modified",
          "value": "Wed, 30 Apr 2014 21:01:19 GMT"
        },
        {
          "name": "Server",
          "value": "Apache/2.4.4 (Unix) OpenSSL/1.0.1 PHP/5.4.12"
        },
        {
          "name": "ETag",
          "value": "\"8bd-4f848d99ceae4\""
        },
        {
          "name": "Content-Type",
          "value": "application/javascript"
        },
        {
          "name": "Connection",
          "value": "Keep-Alive"
        },
        {
          "name": "Accept-Ranges",
          "value": "bytes"
        },
        {
          "name": "Keep-Alive",
          "value": "timeout=5, max=100"
        },
        {
          "name": "Content-Length",
          "value": "2237"
        }
      ],
      "cookies": [],
      "content": {
        "size": 2237,
        "mimeType": "application/javascript",
        "compression": 0,
        "text": "..."
      },
      "redirectURL": "",
      "headersSize": 321,
      "bodySize": 2237
    },
    "cache": {},
    "timings": {
      "blocked": 2.418000000034226,
      "dns": 69.07200000023295,
      "connect": 182.09600000045612,
      "send": 0.08100000013655517,
      "wait": 235.99800000010873,
      "receive": 1.0619477834552526,
      "ssl": 181.40800000037416
    },
    "connection": "49670",
    "pageref": "page_2"
  },

正如预期的那样,在第3个请求中,ETAG和Last-Modified都很好,因此apache服务器发回304响应代码:

      {
    "startedDateTime": "2014-04-30T21:14:56.248Z",
    "time": 138.21721076965332,
    "request": {
      "method": "GET",
      "url": "https://someserver/resource.js",
      "httpVersion": "HTTP/1.1",
      "headers": [
        {
          "name": "If-None-Match",
          "value": "\"8bd-4f848d99ceae4\""
        },
        {
          "name": "Accept-Encoding",
          "value": "gzip,deflate,sdch"
        },
        {
          "name": "Host",
          "value": "someserver"
        },
        {
          "name": "Accept-Language",
          "value": "en-US,en;q=0.8"
        },
        {
          "name": "User-Agent",
          "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36"
        },
        {
          "name": "Accept",
          "value": "*/*"
        },
        {
          "name": "Referer",
          "value": "https://someserver"
        },
        {
          "name": "Cookie",
          "value": "__utma=37592696.1580400495.1393617937.1393617937.1394060568.2; __utmz=37592696.1393617937.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); m=1933:60%7C5|2491:chart|34e2:|4e71:small"
        },
        {
          "name": "Connection",
          "value": "keep-alive"
        },
        {
          "name": "If-Modified-Since",
          "value": "Wed, 30 Apr 2014 21:01:19 GMT"
        }
      ],
      "queryString": [],
      "cookies": [
        {
          "name": "__utma",
          "value": "37592696.1580400495.1393617937.1393617937.1394060568.2",
          "expires": null,
          "httpOnly": false,
          "secure": false
        },
        {
          "name": "__utmz",
          "value": "37592696.1393617937.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)",
          "expires": null,
          "httpOnly": false,
          "secure": false
        },
        {
          "name": "m",
          "value": "1933:60%7C5|2491:chart|34e2:|4e71:small",
          "expires": null,
          "httpOnly": false,
          "secure": false
        }
      ],
      "headersSize": 653,
      "bodySize": 0
    },
    "response": {
      "status": 304,
      "statusText": "Not Modified",
      "httpVersion": "HTTP/1.1",
      "headers": [
        {
          "name": "Date",
          "value": "Wed, 30 Apr 2014 21:14:56 GMT"
        },
        {
          "name": "ETag",
          "value": "\"8bd-4f848d99ceae4\""
        },
        {
          "name": "Server",
          "value": "Apache/2.4.4 (Unix) OpenSSL/1.0.1 PHP/5.4.12"
        },
        {
          "name": "Connection",
          "value": "Keep-Alive"
        },
        {
          "name": "Keep-Alive",
          "value": "timeout=5, max=100"
        }
      ],
      "cookies": [],
      "content": {
        "size": 2237,
        "mimeType": "application/javascript",
        "text": "..."
      },
      "redirectURL": "",
      "headersSize": 203,
      "bodySize": 0
    },
    "cache": {},
    "timings": {
      "blocked": 5.732999999963795,
      "dns": -1,
      "connect": -1,
      "send": 0.07100000038917642,
      "wait": 118.89599999994971,
      "receive": 13.51721076935064,
      "ssl": -1
    },
    "connection": "51334",
    "pageref": "page_1"
  },

如果有人知道为什么第一个请求返回了错误的页面,请告诉我。

0 个答案:

没有答案