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

  • Home
  • SEARCH
  • 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 4568014
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:00:55+00:00 2026-05-21T19:00:55+00:00

Context: ASP.NET MVC 3.0, .NET 4.0, C#, IIS 7 I have a long list

  • 0

Context: ASP.NET MVC 3.0, .NET 4.0, C#, IIS 7

I have a long list of names (of game realms/servers). The realms are stored in a database.
I have an Action that returns the list as a JSON code.

I reference the list in my .aspx as following:

<script type="text/javascript" src='<%= Url.Action("Realms", "Data") %>'></script>

Here is an abbreviated action itself:

    public ActionResult Realms() {
        var realms = Data.GetRealms(...);
        var json = JsonSerialize(realms);
        return Content("realms = {0};".With(json), "text/javascript", Encoding.UTF8);
    }

This list changes very seldom (once a month).

Question: how can I cause this .js file be cached client side?

Details
My problem is that this “file” is being downloaded on each page refresh and accounts for 20% of the traffic.

  • 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-21T19:00:56+00:00Added an answer on May 21, 2026 at 7:00 pm

    how can I cause this .js file be cached client side?

    It would be more reliable to cache it on the server by decorating the action with the [OutputCache] attribute. If you want to cache it on the client you could configure the cache cache location on the client when using this attribute which will send the proper Cache-Control HTTP response header:

    [OutputCache(Location = OutputCacheLocation.Client, Duration = 20)]
    public ActionResult Realms()
    {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Context: ASP.NET MVC 2.0, C#, SQL Server 2008, IIS7 I have 'scheduledMeetings' table in
Setting up ASP.net MVC with Linq2SQL or Entity Framework's context to have scaffolding work
i have published asp.net mvc application on iis 6 on the server(windows server 2003)
I have an ASP.NET MVC web application running in IIS as a subweb; let's
We have a web server running IIS 6.0 and ASP.NET MVC, that is serving
I have an ASP.NET 4.0 MVC web application running on IIS 6.0 with a
I have problem with starting processes in impersonated context in ASP.NET 2.0. I am
I am trying to have a parallel functionality in my asp.net mvc 2 application.
I have an ASP.NET MVC application for which I store uploaded content files in
By ASP.NET MVC plugin architecture, Plug-in architecture for ASP.NET MVC I have separated DLL(plugin)

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.