diff --git a/src/cache.c b/src/cache.c index a2d93758f..698395f15 100644 --- a/src/cache.c +++ b/src/cache.c @@ -646,6 +646,7 @@ enum act_return http_action_store_cache(struct act_rule *rule, struct proxy *px, struct shared_context *shctx = shctx_ptr(cconf->c.cache); struct cache_st *cache_ctx = NULL; struct cache_entry *object, *old; + unsigned int key = *(unsigned int *)txn->cache_hash; /* Don't cache if the response came from a cache */ if ((obj_type(s->target) == OBJ_TYPE_APPLET) && @@ -661,6 +662,10 @@ enum act_return http_action_store_cache(struct act_rule *rule, struct proxy *px, if (txn->meth != HTTP_METH_GET) goto out; + /* cache key was not computed */ + if (!key) + goto out; + /* cache only 200 status code */ if (txn->status != 200) goto out; @@ -800,7 +805,8 @@ enum act_return http_action_store_cache(struct act_rule *rule, struct proxy *px, if (cache_ctx) { cache_ctx->first_block = first; - object->eb.key = (*(unsigned int *)&txn->cache_hash); + object->eb.key = key; + memcpy(object->hash, txn->cache_hash, sizeof(object->hash)); /* Insert the node later on caching success */ diff --git a/src/proto_http.c b/src/proto_http.c index bf661ed44..25e0e3efd 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -7222,6 +7222,7 @@ void http_init_txn(struct stream *s) ? (TX_NOT_FIRST|TX_WAIT_NEXT_RQ) : 0); txn->status = -1; + *(unsigned int *)txn->cache_hash = 0; txn->cookie_first_date = 0; txn->cookie_last_date = 0;