Showing posts with label CSS. Show all posts
Showing posts with label CSS. Show all posts

Saturday, July 21, 2012

How to prevent browser caching for css / javascript

Now a days i have an online shopping site for maintenance.
https://www.izabellondon.com
Since i have done lots of changes in the site, there are situations when we upload new css or javascript but client can not see the new changes because by default browser loads the css or javascript file from its cache memory if the URL is repeated. 


Then we have to ask our client to please clear your browser cache to get new changes. I am sure many of web developer has to face this situation then i decided not to ask our client for same thing.


I start wondering how to overcome this problem? after some google search i found the solution.


You need to add any random querystring after your call to javascript or css includes. for example.


CSS
<link href="/App_Templates/FrontEnd/Login.css?date=2012-07-02" rel="stylesheet" type="text/css" />


Javascript
<script src="/Content/swfobject.js?version=2" type="text/javascript"></script>


It will resolve the issue and your client will not need to clear the cache to get new changes. Querystring in css/javascript call will always load file from the server instead of browser cache.


:)


wow


Happy Coding :)

Thursday, February 24, 2011

Align a div center of page vertically and horizontally

Today i need to align a div center in page horizontal as well as verticle.


css :
body
{
font-size: 14px;
font-family: verdana, helvetica, sans-serif;
color: #333;
}
p
{
margin: 2em;
}

#centerdiv
{
position: absolute;
top: 50%;
left: 50%;
width: 50em;
height: 26em;
margin-top: -13em; /*set to a negative number 1/2 of your height*/
margin-left: -25em; /*set to a negative number 1/2 of your width*/
border: 1px solid #ccc;
background-color: #f3f3f3;
}


html is :