actix-web icon indicating copy to clipboard operation
actix-web copied to clipboard

`CacheDirective` enum is missing some directives

Open ssokolow opened this issue 3 years ago • 3 comments

Expected Behavior

I should be able to use CacheDirective::Immutable for implementing Cache-Control headers for the cache-busting pattern.

Current Behavior

I have to use CacheDirective::Extension("immutable".to_owned(), None)

Possible Solution

Add CacheDirective variants for the following variants listed on MDN but missing from the enum:

  • must-understand
  • immutable
  • stale-while-revalidate
  • stale-if-error

Your Environment

  • Rust Version (I.e, output of rustc -V): rustc 1.59.0 (9d1b2106e 2022-02-23)
  • Actix Web Version: 4.0.1

ssokolow avatar Feb 26 '22 03:02 ssokolow

shame this wasn't caught before stable v4 :/

you can implement your own typed headers though

robjtede avatar Mar 01 '22 16:03 robjtede

shame this wasn't caught before stable v4 :/

Yeah, especially since it was just coincidence that I happened to be preparing to get back to work on the project in question around the v4 release.

To be honest, I'm surprised you didn't mark that enum nonexhaustive.

you can implement your own typed headers though

Not really worth the trouble. I only use it in one place (a helper macro for asset routes), so it's more about moving the responsibility for ensuring typos don't creep in to somewhere with more eyeballs.

ssokolow avatar Mar 01 '22 16:03 ssokolow

Since this can't be fixed until v5, I added an updated verison to actix-web-lab: https://docs.rs/actix-web-lab/0.15.0/actix_web_lab/header/struct.CacheControl.html.

robjtede avatar Mar 08 '22 01:03 robjtede