Edited my worker function, but getting same response as with earlier version

Here is the revised message:

I have recently setup a Cloudflare worker with a custom domain. I am trying to redirect users to specific domains based on the current path (domain/code),then by searching for that code in Upstash Redis.

The issue I am facing is that even after updating the Redis key’s value, I keep getting redirected to the previously set value. I believe this is due to caching, but I am unable to figure out how to disable or bypass the caching.

My worker function is:

export default {
  async fetch(request, env) {
    return await handleRequest(request)

async function handleRequest(request) {
  const url = new URL(request.url)
  const path = url.pathname
  const code = path.substring(1)
  const redirect_url = await get_url(code)
  return Response.redirect(redirect_url, 301)

async function get_url(code){
  const response = await fetch(`https://upstash_redis.url`, {
    headers: {
      Authorization: "Bearer Token"
  const data = await response.json()
  if(data.result != null ){
    return data.result
  else {
    return "https://www.example_deafult.com" 

Please let me know if you need any clarification or have any suggestions.

Instead of redirecting like this

you could try

return new Response(`Redirecting to ${redirect_url}`,
  { status: 301,
    headers: {
      'Cache-Control': 'no-cache',
      Location: redirect_url

Using a standard Response allows the setting of response headers.

You might also consider changing the 301 Permanent Redirect status to 307 Temporary Redirect (this indicates the link may change in time, allowing for a disabling out the link)