---
title: "Comment by Robert Pankowecki on \"Verifying JWTs with JWKS in Ruby\" | Hashnode"
description: "Using force: true , skip_nil: true does not work the way you described it in: Our #fetch_jwks method only returns the JSON response if the request was successfu"
url: "https://hashnode.com/posts/verifying-jwts-with-jwks-in-ruby/60601e0238b0e14f092a32cc/comment/612df7e64e9d8114f8adde07"
---

[Discussion](https://hashnode.com/posts/verifying-jwts-with-jwks-in-ruby/60601e0238b0e14f092a32cc)

Comment [Verifying JWTs with JWKS in Ruby](https://hashnode.com/posts/verifying-jwts-with-jwks-in-ruby/60601e0238b0e14f092a32cc)

[Robert Pankowecki](https://hashnode.com/@robertpank)

[Aug 31, 2021](https://hashnode.com/posts/verifying-jwts-with-jwks-in-ruby/60601e0238b0e14f092a32cc/comment/612df7e64e9d8114f8adde07)

Using

```
force: true, skip_nil: true
```

does not work the way you described it in:

> Our #fetch\_jwks method only returns the JSON response if the request was successful, and nil otherwise. Meaning we can cater for any failed response by leaving the current value in the cache, so we always have the latest successful response we've received.

The cache will be cleared even if the response is not successful and fetch\_jwks returns nil.

```
Rails.cache.fetch("JWKS_CACHE_KEY", force: true, skip_nil: true) do
  Time.now.to_s  
end  
=> "2021-08-31 11:22:32 +0200"

Rails.cache.fetch("JWKS_CACHE_KEY", force: true, skip_nil: true) do
  nil  
end  
=> nil

Rails.cache.fetch("JWKS_CACHE_KEY")
=> nil
```

[Unathi Chonco](https://hashnode.com/@unathi)

[Aug 31, 2021](https://hashnode.com/posts/verifying-jwts-with-jwks-in-ruby/60601e0238b0e14f092a32cc/comment/612df7e64e9d8114f8adde07#reply-612e26904e9d8114f8ade7ec)

[Robert Pankowecki](https://hashnode.com/@robertpank) Nice catch. It looks like you're correct. An oversight while writing this. The issue here is using `force: true` and `skip_nil: true` at the same time. `force` is always going to force a cache write. So actually using them together would require splitting up the logic.

Thanks for pointing this out
