Search code examples
asp.netcachinghttp-redirectpagespeed

Caching redirects in asp.net


Recently i was testing site performance on PageSpeed, where i came to know that we have Landing page issues, here's what PageSpeed told us:

To speed up page load times for visitors of your site, remove as many landing page redirections as possible, and make any required redirections cacheable if possible.

It further says:

http://www.avnetwork.com/ is a non-cacheable redirect to http://www.avnetwork.com/index

Can anyone tell me how to cache the redirects in asp.net


Solution

  • Programatically you can try something like this:

    Response.Cache.SetExpires(DateTime.Now.AddDays(1));
    Response.Cache.SetCacheability(HttpCacheability.Private);
    Response.Cache.SetValidUntilExpires(true);
    Response.AddHeader("Vary", "User-Agent, Accept-Encoding");
    Response.Redirect("http://www.avnetwork.com/index");