Question:
How to make Redis cache in .NET 8 work?

To get the cache working, you need to call app.UseOutputCache(); after routing app.UseRouting(); which is somewhere in your Programs.cs in your frontend project.


So your code should be something like


var builder = DistributedApplication.CreateBuilder(args);


var cache = builder.AddRedisContainer("rediscache");

builder.AddProject<Projects.WeatherApp_Web>("frontend")

    .WithReference(cache)


var app = builder.Build();


etc...


app.UseRouting();

app.UseOutputCache();


etc...


[OutputCache(Duration = 5)]


Suggested blogs:

>How to do PHP Decryption from Node.js Encryption?

>How to do PHP gd Installation on Ubuntu?

>How to do Web Scraping with Python?

>How to do wild grouping of friends in Python?

>How to download an entire S3 bucket - Complete Guide

>How to get item details of Woo Commerce in custom email content?

>How to install Laravel using composer and configure?


Ritu Singh

Ritu Singh

Submit
0 Answers