Implemented Response Cashing
This commit is contained in:
@ -26,6 +26,7 @@ namespace HPlusSportsAPI.Controllers
|
||||
|
||||
[HttpGet]
|
||||
[Produces(typeof(DbSet<Customer>))]
|
||||
[ResponseCache(Duration = 60)]
|
||||
public IActionResult GetCustomer()
|
||||
{
|
||||
var results = new ObjectResult(_customerRepository.GetAll())
|
||||
@ -40,6 +41,7 @@ namespace HPlusSportsAPI.Controllers
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[Produces(typeof(Customer))]
|
||||
[ResponseCache(Duration = 60)]
|
||||
public async Task<IActionResult> GetCustomer([FromRoute] int id)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
|
||||
@ -36,6 +36,8 @@ namespace H_Plus_Sports
|
||||
services.AddScoped<IProductRepository, ProductRepository>();
|
||||
services.AddScoped<ISalespersonRepository, SalespersonRepository>();
|
||||
|
||||
services.AddResponseCaching();
|
||||
|
||||
services.AddMvc(option => option.EnableEndpointRouting = false)
|
||||
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
|
||||
.AddNewtonsoftJson(opt => opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore);
|
||||
@ -53,6 +55,8 @@ namespace H_Plus_Sports
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseResponseCaching();
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
Reference in New Issue
Block a user