asp.net - Why is the page at one URL using the cached page from another URL? -


background

i'm pretty new asp.net , new concept of caching. i'm hoping knows they're doing, problem here obvious.

using mcms 2002, built template.aspx page receives "person_id" query string , builds pages accordingly. several different departments @ school work using template display faculty biographies. working correctly.

the problem

the problems start happening when try caching page. when person visits person_id=16175 on 1 department's page, visits same numeric bio on different department page, loads cached page instead of rebuilding it. problem, then, has of wrong department branding. example:

http://health.usf.edu/medicine/obgyn/facstaf/profiles.htm?person_id=16175 http://health.usf.edu/medicine/surgery/surgery_bios.html?person_id=16175

it's same person_id, urls different. great if template recognize different urls , ignore cache. i'm assuming problem lies in fact both pages being built using same aspx page on backend. here's outputcache bit aspx page:

<%@ outputcache duration="86400" location="server" varybyparam="person_id; section" varybycustom="cmsposting" varybyheader="referer" %> 

i assume i'm doing wrong here. obvious knows they're doing. if need more info, don't hesitate ask. thanks!

your correct in assumption being because use same aspx file, have experienced same firsthand. around issue try following.

try output cache directive

<%@ outputcache location="server" varybycustom="url" duration="60" varybyparam="*" %> 

and add in global.asax file.

public override string getvarybycustomstring(httpcontext context,string arg) {     if (arg == "url")     {          return context.request.rawurl;     }     return context.request.rawurl;//you can vary other stuff here } 

a version of page cached every unique value returned method given argument. returning url ensure cache not hit different urls

a key thing note if not have single physical file resolving multiple urls varybyparam="*" enough desired behaviour. it's because have url routing require varybycustom="url"


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -