Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6662501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:23:46+00:00 2026-05-26T02:23:46+00:00

I wonder how can I cache webservice returned data by its passed argument? For

  • 0

I wonder how can I cache webservice returned data by its passed argument?

For example:

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string FunctionThatReturnsSomething(int param1){
   ... does something
return strResult;

}

What I want is that the returned the webservice returned data will be cached, but according to the parameter value (inr param1). So if, for example, the webservice function gets a value of ‘1’, it will cache the results for that. If the functions gets ‘2’ integer for the param1, it will cache another result.

note: the webmethod/webservice is being called via Ajax call using POST method.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:23:47+00:00Added an answer on May 26, 2026 at 2:23 am

    ASP.NET handily provides the Application Cache just for this sort of thing.

    In it’s simplest form, you can just add data to the cache like this:

    HttpRuntime.Cache["Key"] = "Value"; 
    

    So you could cache the data that you want to return easily:

    string cacheKey = "FunctionThatReturnsSomething_" + param1.ToString();
    
    if (HttpRuntime.Cache[cacheKey] == null)
    {
        string myData = GetDataToReturn(param1);
    
        HttpRuntime.Cache[cacheKey] = myData; 
    }
    
    return (string)HttpRuntime.Cache[cacheKey];
    

    It also allows you to specify a CacheDependancy. So for example if your data was based on a local file, you can have the cache automatically cleared if that file is updated.

    You can also have data that you enter into the cache removed after a certain time, for example if it hasn’t been used for 10 minutes:

    HttpRuntime.Cache.Insert(cacheKey, myData, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 10, 0));
    

    Or at an absolute time, such as 10 minutes after you add it:

    HttpRuntime.Cache.Insert(cacheKey, myData, null, DateTime.Now.AddMinutes(10), 
    System.Web.Caching.Cache.NoSlidingExpiration);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something like this $.ajaxSetup({ cache: false }); I am wonder can you
I wonder how can i remove all string part after #. For example if
Here is the Response I wonder how can I handle a JSON Response like
I wonder how can i read a xml data and transform it to a
I wonder how can I export a Visual Studio C++ project to Qt? I
I am going to develop ICQ client and I just wonder where can I
Out of curiosity, I wonder what can people do with parsers, how they are
I'd like to start coding for NVIDIA 3D Vision and wonder where can I
Wonder if anyone can help me understand how to sum up the column of
wonder whether someone can help me with the following one... I have a struct

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.