visit_url() caching issues?

szepherd

New member
So here's a funny problem. The following code retrieves and compares the lengths of two wiki pages:

Code:
void main(){
	string SS = "http://kol.coldfront.net/thekolwiki/index.php/The_Sonata_of_Sneakiness";
	string SSE = "http://kol.coldfront.net/thekolwiki/index.php/The_Sonata_of_Sneakiness_(effect)";
	string AT = "http://kol.coldfront.net/thekolwiki/index.php/Accordion_Thief";
	
	SS = visit_url(SS);
	//AT = visit_url(AT);
	SSE = visit_url(SSE);
	if(length(SS) == length(SSE))
		print("same");
	else
		print("different");
	
}

They are different pages, however the script returns "same". If I un-comment this line, however:

Code:
	//AT = visit_url(AT);


the code returns "different". Is Mafia caching the page and not comparing the two url's in their entirety? Any other thoughts?
 
Last edited:

Spiny

Member
Some testing with a little friendly help from Quanta proves that you're right. It is caching and isn't using exact URL match, but contains_text match instead. You'd have to visit a distinctly different URL in between visits to similarly named pages to sidestep this, unless there is another known way to clear the visit_url buffer. Probably is a way to do this, but I'm not savvy enough to know how ;)

Also, not sure what your intent was, but perhaps you wanted to visit the skill page, effect page and class page. In which case the first URL should have _(skill) at the end of it.
 

szepherd

New member
This is just sample code, actually.

What the actual script does is go through Mafia's effect list and parse the wiki pages for those effects to get all the items that generate them and their corresponding turn counts. Most effect names can be tacked directly onto the main wiki url to get the pages, but a few lead to disambiguation pages. I ran across this problem when I tried adding a "_(effect)" to the url of anything that resulted in such a page and kept getting the same results. Drove me pretty crazy for a while, actually. :)

The ultimate purpose here is to have turn counts for effects to make my basement-diving script a bit more price-efficient. I'll probably post that once I'm happy with its operation. Thanks for confirmation of the issue!
 

jasonharper

Developer
This wasn't an issue with caching - the problem is that a new URL that starts with the previous entire URL was assumed to actually be the same URL with different parameters, so the URL itself was reused. That's always true on KoL itself, but not the Web in general. Fixed in r7654.
 
Top