Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

It is a very common practice for the testers while testing any issue to clear cache, temporary files, when any styling changes are updated on the website.

And we can't expect the same action from the end users to see the changes.
Currently we are facing this issue in our projects.

So, what are the different ways or techniques we can follow while deployment to reflect the changes without clearing the cache or temporary files on browsers ?

Any help or suggestion will be appreciated.

Thanks,
Tadit.

There is a way to do it automatically,

In Assembly, set the version number.

in code behind, get the assembly version
protected string getversion()
{
    return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
}


In aspx,
<link rel="stylesheet" href="../css/test.css?<%= getversion(); %>" type="text/css" />


cheers
 
Share this answer
 
Comments
I thing this will solve our problem.
Let me implement this and come back to you.
And I will put some ratings after the implementation succeeds.

Thanks a lot Sandip.
If you really want end users to see the style changes quicker, change the name of the style sheet, so the browser knows it's a new one. Personally, once I release something, I expect that it works fine, and if end users look at the old style for a bit, I don't see a huge issue with that.

Your other option is to set 'cache-control: "no-cache, must-revalidate"'[^]
 
Share this answer
 
Comments
Hi Christian,

Thanks for your reply.

FYI - Actually we can't let users see the old styles in our projects as we also fix bugs in different browsers and many functionality also depend on the changes, which client also complains.

1st attempt of renaming the files
---------------------------------
As we are working on a very big project, we have lots of pages.
So, if we will change the name of the style sheet, then we have to do this in every page, which is not possible in our projects as it will take a huge time and client will also not approve this.

2nd attempt of cache control
----------------------------
I am not able to get the concept.
Can you please elaborate in brief ?
Also if you can give one example of code how to do this, it would be helpful.

Thanks,
Tadit
Christian Graus 21-Aug-12 9:50am    
Option 1 is clearly messy. Option 2 involves changing the headers in your response, so I don't know how messy it is, I just googled for you and that appears to be the only option, it forces the browser to check for an update right away. http://forums.asp.net/t/979853.aspx/1 seems to cover how this is done, it's pretty top level in your application. Either way, it seems messy
The best technique is to use versioning to your css and js file.

<script type="text/javascript" src="../js/test.js?1.1.1.1" ></script>

<link rel="stylesheet" href="../css/test.css?1.1.1.1." type="text/css" />


cheers
 
Share this answer
 
v2
Comments
As I have commented on the answer by Christian that we have many pages which use the same style sheet file.
So, if we will version the css and js files, we need to do the same in every page, which will take a huge time according our project architecture.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900