1

I'm trying to improve my site performance using output cache. The problem is that the site is in 2 languages. The site is a sharepoint site. I use:

<%@ OutputCache Duration="1800" VaryByParam="None" %>

on the user control of my navigation visual web part. On code behing when I switch language

protected void ddlLanguages_SelectedIndexChanged(object sender, EventArgs e)
    {
        string selectedValue = ddlLanguages.SelectedValue.ToString();
        if (!String.IsNullOrEmpty(selectedValue))
        {
            IISCommonFunctions.IISCurrentEnvironment.SetLanguage(selectedValue);

            HttpResponse.RemoveOutputCacheItem("/_controltemplates/Services/NavigationWebPart.ascx");
            Response.Redirect(Request.Path);

        }
    }

But the problem here is that nothing happens. Nothing is cleared from cache. Maybe the virtual path it's not right?

0

Your Code behind won't be executed anymore once the page / component is in cache. You could point to the same url with a different querystring (eg : ?lg=fr) and have this query string parameter in your output cache declaration

<%@ OutputCache Duration="1800" VaryByParam="lg" %>

Alternatively, it's often better to rely on the output cache profile / framework of SharePoint, within it you'll also be able to adapt your varbyparam / varybycustom without implementing it on all your user control / webparts / pages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.