0

This is my EmployeeDetailsController.cs

namespace EmpApi.Controllers
{
    [RoutePrefix("")]

    public class EmployeeDetailsController : ApiController
    {

        [HttpGet]

        [Route("Employees")]

        public IEnumerable<Employee> Employees()
        {

        }


        [HttpGet]
        [Route("Details/{id}")]
        public IEnumerable<Details> Details(int id)
        {
        }


        [HttpGet]
        [Route("TeamInfo/{id}")]
        public IEnumerable<Team> TeamInfo(int id)
        {

        }

        [HttpGet]
        [Route("DetailsForTeam/{id}")]
        public IEnumerable<Details> DetailsForTeam(int id)
        {
            ;
        }
        [HttpPost]
        [Route("PostEmp")]
        public void PostEmp([FromBody] Employee cs)
        {

        }
        [HttpPut]
        [Route("PutEmp/{id}")]
        public void PutEmp(int id, [FromBody]Employee cs)
        {

        }
        [HttpDelete]
        [Route("DeleteEmp/{id}")]
        public void DeleteEmp(int id)
        {

        } 
    }
}

I made an API which has various services. Suppose i call api/Employees,after i call api/Details/12 and then when i click GoBack button in browser, api/Employees should not be triggered. How do i enable cache for my API.Please tell me the steps as I am new in WebApI. Thanks in advance..

Mahek
  • 552
  • 2
  • 7
  • 28

1 Answers1

0

Add this code before your controller declaration as follows:

[OutputCache(VaryByParam = "*", Duration = 0, NoStore = true)]
public class EmployeeDetailsController : ApiController
{
...
}
oɔɯǝɹ
  • 7,219
  • 7
  • 58
  • 69
Chaos Legion
  • 2,730
  • 1
  • 15
  • 14