JoeDog / siege

Siege is an http load tester and benchmarking utility
GNU General Public License v3.0
5.9k stars 386 forks source link

Requests that should be cache don't seem to be cached #214

Open cvortmann opened 1 year ago

cvortmann commented 1 year ago

Even though siege -C shows cache enabled: true and running a single request with the -g option returns the following HTTP Headers from Cloudfare:

CF-Cache-Status: HIT
Age: 283

And the response itself include the following Cache-Control Header:

Cache-Control: max-age=600, must-revalidate, no-transform

The output of running multiple requests with, for example, -c100 -T10M is still shown in blue and without (C) beside it.

I've tried with some of our projects public URLs but also with any image URL returned by a Search tool. None of them look like they were being cached.

Expectation: first request is blue and the following requests are green (with (C) beside it).


I'm using Siege in MacOS through homebrew:

❯ siege -V
SIEGE 4.1.5

Copyright (C) 2022 by Jeffrey Fulmer, et al.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.
JoeDog commented 1 year ago

Could you send me some public URLs so I can replicate the problem?

On Thu, Oct 6, 2022 at 6:19 AM Cesar Henrique Vortmann < @.***> wrote:

Even though siege -C shows cache enabled: true and running a single request with the -g option returns the following HTTP Headers from Cloudfare:

CF-Cache-Status: HIT

Age: 283

And the response itself include the following Cache-Control Header:

Cache-Control: max-age=600, must-revalidate, no-transform

The output of running multiple requests with, for example, -c100 -T10M is still shown in blue and without (C) beside it.

I've tried with some of our projects public URLs but also with any image URL returned by a Search tool. None of them look like they were being cached.

Expectation: first request is blue and the following requests are green (with (C) beside it).

I'm using Siege in MacOS through homebrew:

❯ siege -V

SIEGE 4.1.5

Copyright (C) 2022 by Jeffrey Fulmer, et al.

This is free software; see the source for copying conditions.

There is NO warranty; not even for MERCHANTABILITY or FITNESS

FOR A PARTICULAR PURPOSE.

— Reply to this email directly, view it on GitHub https://github.com/JoeDog/siege/issues/214, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJRHZXOSCLG664MBYQ26PLWB2RSNANCNFSM6AAAAAAQ6OPZDU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Jeff Fulmer 1-717-799-8226 https://www.joedog.org/ He codes

cvortmann commented 1 year ago

@JoeDog sure. You can try with the following URL:

https://www.mcknightsseniorliving.com/wp-content/uploads/sites/3/2020/01/llama_GettyImages-1037120268_2000x1125.jpg

It has the following response headers:

Cache-Control: max-age=2592000

The output for me was (both entries in blue):

❯ siege -c1 --reps=2 "https://www.mcknightsseniorliving.com/wp-content/uploads/sites/3/2020/01/llama_GettyImages-1037120268_2000x1125.jpg"
** SIEGE 4.1.5
** Preparing 1 concurrent users for battle.
The server is now under siege...
HTTP/1.1 200     0.11 secs:  219252 bytes ==> GET  /wp-content/uploads/sites/3/2020/01/llama_GettyImages-1037120268_2000x1125.jpg
HTTP/1.1 200     0.10 secs:  219252 bytes ==> GET  /wp-content/uploads/sites/3/2020/01/llama_GettyImages-1037120268_2000x1125.jpg

Transactions:                  2 hits
Availability:             100.00 %
Elapsed time:               0.22 secs
Data transferred:           0.42 MB
Response time:              0.11 secs
Transaction rate:           9.09 trans/sec
Throughput:             1.90 MB/sec
Concurrency:                0.95
Successful transactions:           2
Failed transactions:               0
Longest transaction:            0.11
Shortest transaction:           0.10
JoeDog commented 1 year ago

I'm gonna need a little time to debug this.

On Fri, Oct 7, 2022 at 3:20 AM Cesar Henrique Vortmann < @.***> wrote:

@JoeDog https://github.com/JoeDog sure. You can try with the following URL:

https://www.mcknightsseniorliving.com/wp-content/uploads/sites/3/2020/01/llama_GettyImages-1037120268_2000x1125.jpg

It has the following response headers:

Cache-Control: max-age=2592000

The output for me was:

❯ siege -c1 --reps=2 "https://www.mcknightsseniorliving.com/wp-content/uploads/sites/3/2020/01/llama_GettyImages-1037120268_2000x1125.jpg"

** SIEGE 4.1.5

** Preparing 1 concurrent users for battle.

The server is now under siege...

HTTP/1.1 200 0.11 secs: 219252 bytes ==> GET /wp-content/uploads/sites/3/2020/01/llama_GettyImages-1037120268_2000x1125.jpg

HTTP/1.1 200 0.10 secs: 219252 bytes ==> GET /wp-content/uploads/sites/3/2020/01/llama_GettyImages-1037120268_2000x1125.jpg

Transactions: 2 hits

Availability: 100.00 %

Elapsed time: 0.22 secs

Data transferred: 0.42 MB

Response time: 0.11 secs

Transaction rate: 9.09 trans/sec

Throughput: 1.90 MB/sec

Concurrency: 0.95

Successful transactions: 2

Failed transactions: 0

Longest transaction: 0.11

Shortest transaction: 0.10

— Reply to this email directly, view it on GitHub https://github.com/JoeDog/siege/issues/214#issuecomment-1271206313, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJRHZQDFTUG7YWCG656G7DWB7FNTANCNFSM6AAAAAAQ6OPZDU . You are receiving this because you were mentioned.Message ID: @.***>

-- Jeff Fulmer 1-717-799-8226 https://www.joedog.org/ He codes

JoeDog commented 1 year ago

Wait a second. The image expires yesterday. I need to re-read the RFCs for a final verdict on precedence, but I don't think I've ever encountered a discrepancy between Expires and Cache-control. I would expect them to be in sync.

HTTP/1.1 200 OK Date: Sun, 09 Oct 2022 23:01:29 GMT Content-Type: image/jpeg Content-Length: 219252 Connection: close Cache-Control: max-age=2592000 Cf-Bgj: h2pri Content-Security-Policy: frame-ancestors 'self' https://www.mycme.com/ https://mycmesandbox.thoughtindustries.com https://nacesandbox.thoughtindustries.com https://www.naceonline.com/ ETag: "317f1cc620e91b89450b9b99cc82a816" Expires: Tue, 08 Nov 2022 08:44:48 GMT Last-Modified: Tue, 21 Jan 2020 07:10:19 GMT x-amz-server-side-encryption: AES256 CF-Cache-Status: HIT Age: 130 Accept-Ranges: bytes Vary: Accept-Encoding Server: cloudflare CF-RAY: 757abd0de8808cae-EWR

On Sun, Oct 9, 2022 at 7:00 PM Jeff Fulmer @.***> wrote:

I'm gonna need a little time to debug this.

On Fri, Oct 7, 2022 at 3:20 AM Cesar Henrique Vortmann < @.***> wrote:

@JoeDog https://github.com/JoeDog sure. You can try with the following URL:

https://www.mcknightsseniorliving.com/wp-content/uploads/sites/3/2020/01/llama_GettyImages-1037120268_2000x1125.jpg

It has the following response headers:

Cache-Control: max-age=2592000

The output for me was:

❯ siege -c1 --reps=2 "https://www.mcknightsseniorliving.com/wp-content/uploads/sites/3/2020/01/llama_GettyImages-1037120268_2000x1125.jpg"

** SIEGE 4.1.5

** Preparing 1 concurrent users for battle.

The server is now under siege...

HTTP/1.1 200 0.11 secs: 219252 bytes ==> GET /wp-content/uploads/sites/3/2020/01/llama_GettyImages-1037120268_2000x1125.jpg

HTTP/1.1 200 0.10 secs: 219252 bytes ==> GET /wp-content/uploads/sites/3/2020/01/llama_GettyImages-1037120268_2000x1125.jpg

Transactions: 2 hits

Availability: 100.00 %

Elapsed time: 0.22 secs

Data transferred: 0.42 MB

Response time: 0.11 secs

Transaction rate: 9.09 trans/sec

Throughput: 1.90 MB/sec

Concurrency: 0.95

Successful transactions: 2

Failed transactions: 0

Longest transaction: 0.11

Shortest transaction: 0.10

— Reply to this email directly, view it on GitHub https://github.com/JoeDog/siege/issues/214#issuecomment-1271206313, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJRHZQDFTUG7YWCG656G7DWB7FNTANCNFSM6AAAAAAQ6OPZDU . You are receiving this because you were mentioned.Message ID: @.***>

-- Jeff Fulmer 1-717-799-8226 https://www.joedog.org/ He codes

-- Jeff Fulmer 1-717-799-8226 https://www.joedog.org/ He codes

cvortmann commented 1 year ago

According to mdn web docs, if both Expires and Cache-Control: max-age are present, the later is defined to preferred.

cvortmann commented 1 year ago

And thanks @JoeDog for taking the time to look this up. I'll try to help as I can.