1

Topic: MVC 5 - Why does not work OutputCache?

Here the code of a method of the controler: [OutputCache (Location = OutputCacheLocation. Any, VaryByParam = "none", Duration = 60)] public ActionResult Index (string country = null, string city = null, string companyName = null, int page = 1, int pageSize = 5, string sort = "ContactName", string sortdir = "DESC") {var allCustomers = service. GetCustomers (country, city, companyName); return View (allCustomers);} Vjuha: @using (Html. BeginForm ("index", null, FormMethod. Get)) {<div style = "margin-top:17px;"> {var grid = new WebGrid (canPage: true, rowsPerPage: Model. PageSize, canSort: true, ajaxUpdateContainerId: "grid"); grid. Bind (Model. Content, rowCount: Model. TotalRecords, autoSortAndPage: false); grid. Pager (WebGridPagerModes. All); @grid. GetHtml (htmlAttributes: new {id = "grid"}, fillEmptyRows: false, tableStyle:" table table-bordered table-hover ", mode: WebGridPagerModes. All, columns: grid. Columns (grid. Column (" CustomerID "," CustomerID "), grid. Column (" CompanyName "," CompanyName "), grid. Column (" ContactName "," ContactName "), grid. Column (" City "," City ", style:"col-lg-3"), grid. Column (" Country "," Country ", style:"col-lg-3")));} </div>} Why the controler method is called each time when the browser goes on page, even if at pushing F5?

2

Re: MVC 5 - Why does not work OutputCache?

Hello, Glestwid, you wrote: G> Why the controler method is called each time when the browser goes on page, even if at pushing F5? Add in web.config <system.webServer> <urlCompression dynamicCompressionBeforeCache = "false"/> </system.webServer> Look that the server in titles gives (should not be Vary: *).