HTTP 缓存管理器不缓存请求内容

HTTP Cache Manager not caching request contents

我的测试计划:

Test Plan
+ User Defined Variables
++ Thread Group
+++ HTTP Cache Manager
+++ Transaction Controller
++++ Request 1
+++ Transaction Controller
++++ Request 2

在 运行 测试之后,我可以在 查看 Table 中的结果,两个请求的传输字节相同。 HTTP Cache Manager 的功能是否取消了这种行为? 下面是一张显示我的 HTTP 请求的图像,请注意传输的字节对所有请求都是相同的。

真实测试计划:

缓存管理器附带 documentation 中列出的许多条件,因此请务必查看它们:

  1. 你有"groups of 3"的事实是正常的:

    Each Virtual User thread has its own Cache.

    所以每个请求都会执行3次,每个用户都会有自己的缓存

  2. 根据URL。因此,即使项目 1.1、2.1、3.1 和 4.1 URL 略有不同,每一项都将被缓存。在这种情况下,只有当您在同一请求或下一次迭代中循环时,您才会看到缓存在运行。

  3. 缓存管理器决策基于帮助中定义的特定算法。如果您的请求偏离该算法,它们将不会缓存:

    If a sample is successful (i.e. has response code 2xx) then the Last-Modified and Etag (and Expired if relevant) values are saved for the URL. Before executing the next sample, the sampler checks to see if there is an entry in the cache, and if so, the If-Last-Modified and If-None-Match conditional headers are set for the request.

  4. 最后还有影响缓存的header,例如:

    if Cache-Control header is "no-cache", the response will be stored in cache as pre-expired, so will generate a conditional GET request

    Responses with a Vary header will not be cached.

我通常把缓存管理器和cookie管理器放在最高层。 还要检查是否请求了 "clear cache on each iteration " 标志。 这取决于应用程序要求(每次返回用户或新用户)。

是的,大多数时候只有静态项目被缓存(css、.js、图像),而 html 页面通常是生成的并且不能被缓存。