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 7665743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:39:12+00:00 2026-05-31T14:39:12+00:00

On the site I’m developing, there is a page that lists all of the

  • 0

On the site I’m developing, there is a page that lists all of the users on the site (and some other information) in a table. This page is identical to everyone who logs in (at any given time, at least), except for one difference – their own row is highlighted. So it seemed to me that this would be an ideal candidate for caching – we don’t need every user that hits that page to recalculate and render the data on the page when only that one thing changes.

I attempted to handle this by adding output caching to the page, and moving the highlighting of the table row to JavaScript (a jQuery call) – my hope was that this page would be cached, but the JavaScript would be run every time somebody hits it, resulting in their own row being highlighted. That doesn’t seem to be the case, however. If I hit the site first, my row is highlighted. Then, if somebody else hits the page within the cache expiry time (on a different machine, so it’s not a browser cache thing), they see the page with my row highlighted rather than their own, until the cache expires – and then everybody sees the row highlighted of whoever hit the page next, and so on. It seems like it is serving up the cached version of the page after the JavaScript has been executed, rather than serving up the cached version of the page and then running the JavaScript.

Is there a way to do what I’m trying to do – cache the page so I’m not executing ASP.NET calls every time somebody hits the page, but have the JavaScript run fresh every time the page is loaded so a different row gets highlighted? Or if not with JavaScript is there any way to do this? I thought about using setInterval to do the check for a highlight (and re-highlight the proper row) at regular intervals, but that seems like overkill since this only needs to be done once after the page is loaded, and never done again until the page is reloaded.

Here are the relevant parts of my aspx file:

<%@ OutputCache Duration="60" VaryByParam="none" %>

<script type="text/javascript">

jQuery(document).ready(function($) {
    var isAuthenticated = ('<%= Context.User.Identity.IsAuthenticated %>' == 'True');

    if (isAuthenticated) {
        var owner = '<%= Context.User.Identity.Name %>';

        $('#' + owner).css("background-color", "#bdf");
    }
});

</script>

<table>
    <tr>
        <th>
            Owner
        </th>
        ...
    </tr>

<% foreach (var item in Model.Items) { %>

    <%= String.Format("<tr id=\"{0}\">", item.Owner) %>
        <td>
            <%= Html.Encode(item.Owner) %>
        </td>
        ...
    </tr>

<% } %>

</table>
  • 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-31T14:39:14+00:00Added an answer on May 31, 2026 at 2:39 pm

    The page is cached after the values like Context.User.Identity.IsAuthenticated are evaluated. So even though the JavaScript is executed on the client, it already contains the specific values (your values) from the cache.

    To do this right, you can either

    1. remove those values from the script altogether, and perform an AJAX request to see who is logged in. But remember that the highlighting won’t work at all if the browser has JavaScript disabled.
    2. cache the page per user
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My site has a few pages that point to the same child page. I'm
My site allows users to upload csv files for processing. It all works fine,
Site: http://clientfiles.priworks.com/lgmanagedportfolios/test/investment.html I have been working at this web page for a while now
Site here . Why is it that the code works for $('#club').change(function(event) but not
site.com/link?p=2 give $_GET['p']==2 even though i've already made site.com/link rewrite to site.com/index.php?page=link So, i'm
Site: http://partsconsign.com/parts/?custid=1 I don't know what happened. All of a sudden, without changing the
Site which I am developing has a menu with drop downs, which is always
Site: http://na.leagueoflegends.com/ladders/solo-5x5 Search for a a player (example: Jaiybe) You get redirected (in this
The site I'm working on has a database table filled with glossary terms. I
My site uses an HTML5shiv for the benefit of Internet Explorer 6 users. What

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.