HTTP Client seems to cache Javascript imports too aggressively
Context
We've moved over our HTTP request tooling to Rider and it's great.
We have a service that needs a bearer token that's generated with a certificate (which is installed on our machines for non-production), we generate it with a little bit of C# that we run as a Before Launch step and it writes to C:\Temp\token.js

Which writes the following Javascript snippet to token.js:
export const serviceToken = "myTokenHere"
We then import that token to our environment using the following Javascript in the HTTP request:
import {serviceToken} from "C:\\Temp\\token.js";
client.global.set("service_token", "Bearer " + serviceToken)
Which we can consume with our requests.
Issue
This was working well but coming back to the project after a while it has stopped working. We can see our code running and generating a new token and overwriting the file on disk. However it making requests with an old version of the serviceToken const.
Our best guess is that Rider has some cached copy of token.js or the const. We've invalidated all Rider's caches, restarted, and rebooted and the problem persists.
Please sign in to leave a comment.
Hi Dave Megins-nicholas ,
All HTTP Client caches are stored in the
.ideafolder of the project. You may check whether expired tokens are cached and see if there is any improvement by deleting thehttpRequestsfolder.For your scenario, I think you should try the pre-request script, which is documented here. It's used to refer to external files in each request.
Regards,
Tao