You missed tests for the following routes:
| Endpoint |
Expected Cache-Control |
| /tx |
public, max-age=31536000, immutable |
| /blockfilter |
public, max-age=31536000, immutable |
| /blockfilterheaders |
public, max-age=31536000, immutable |
| /deploymentinfo |
no-store |
| /getutxos |
no-store |
self.log.info("Test Cache-Control headers on REST responses")
blockhash = self.nodes[0].getbestblockhash()
height = self.nodes[0].getblockcount()
txid = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=getnewdestination()[1], amount=int(0.1 * COIN))["txid"]
# Immutable (hash-addressed) endpoints
response = self.test_rest_request(f"/block/{blockhash}", ret_type=RetType.OBJ)
assert_equal(response.getheader("Cache-Control"), "public, max-age=31536000, immutable")
response.read()
response = self.test_rest_request(f"/block/{blockhash}", req_type=ReqType.BIN, ret_type=RetType.OBJ)
assert_equal(response.getheader("Cache-Control"), "public, max-age=31536000, immutable")
response.read()
response = self.test_rest_request(f"/headers/{blockhash}", ret_type=RetType.OBJ, query_params={"count": 1})
assert_equal(response.getheader("Cache-Control"), "public, max-age=31536000, immutable")
response.read()
response = self.test_rest_request(f"/spenttxouts/{blockhash}", ret_type=RetType.OBJ)
assert_equal(response.getheader("Cache-Control"), "public, max-age=31536000, immutable")
response.read()
response = self.test_rest_request(f"/tx/{txid}", ret_type=RetType.OBJ)
assert_equal(response.getheader("Cache-Control"), "public, max-age=31536000, immutable")
response.read()
response = self.test_rest_request(f"/blockfilter/basic/{blockhash}", ret_type=RetType.OBJ)
assert_equal(response.getheader("Cache-Control"), "public, max-age=31536000, immutable")
response.read()
response = self.test_rest_request(f"/blockfilterheaders/basic/{blockhash}", ret_type=RetType.OBJ, query_params={"count": 1})
assert_equal(response.getheader("Cache-Control"), "public, max-age=31536000, immutable")
response.read()
# Short-lived (height-addressed) endpoints
response = self.test_rest_request(f"/blockhashbyheight/{height}", ret_type=RetType.OBJ)
assert_equal(response.getheader("Cache-Control"), "public, max-age=30")
response.read()
# Dynamic (no-store) endpoints
response = self.test_rest_request("/chaininfo", ret_type=RetType.OBJ)
assert_equal(response.getheader("Cache-Control"), "no-store")
response.read()
response = self.test_rest_request("/mempool/info", ret_type=RetType.OBJ)
assert_equal(response.getheader("Cache-Control"), "no-store")
response.read()
response = self.test_rest_request("/deploymentinfo", ret_type=RetType.OBJ)
assert_equal(response.getheader("Cache-Control"), "no-store")
response.read()
response = self.test_rest_request(f"/getutxos/{txid}-0", ret_type=RetType.OBJ)
assert_equal(response.getheader("Cache-Control"), "no-store")
response.read()
# Error responses should not be cached
response = self.test_rest_request(f"/block/{UNKNOWN_PARAM}", status=404, ret_type=RetType.OBJ)
assert_equal(response.getheader("Cache-Control"), "no-store")
response.read()