Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Cache clearing in php website

Posted on 2014-11-19
5
Medium Priority
?
89 Views
Last Modified: 2014-11-20
My website is looking different in different websites. Any update on CSS is not reflecting immediately in firefox but where as safari and chrome show the modification immediately.
Is there a way to add a code which clears the existing cache whenever the website loads and uses the latest style sheet.
0
Comment
Question by:karthik80c
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 36

Expert Comment

by:Kimputer
ID: 40452221
This is done either in the http server through the .htaccess file:

Header set Cache-Control "no-cache, no-store"

or through PHP:

header('Cache-Control: no-cache, no-store');
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40453359
However there is one big limitation; User Settings.  

You have no control over the user setting and the the browser will not refresh cache if the user settings explicitly prevent it;  unfortunately many users have restricted cache setting to optimize response time, especially if they are on a slow connection or use a lot of sites heavy on graphics or videos.

Cd&
0
 

Author Comment

by:karthik80c
ID: 40454390
Thank you Computer and Coboldinosaur.
Coboldinosaur
- then so what would be the best solution for this Coboldinosaur. Please let me know.

Thanks
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 1500 total points
ID: 40454534
When I change files that like CSS and javascript that are part of an HTML page, I often change the names of the files.  The browser usually will re-fetch the main page when it changes and if you have changed the names of the CSS and javascript files, even by a single character, they will fetched because the new names will not be in the cache.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40455689
The solution Dave offers is a commonly used approach.  You can just add the version number to the new file.  The only drawback the approach has is if you are delivering static pages with the file names hard-coded; in which case you will need to change the file name on every page.

Cd&
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will learn how to dynamically set the form action using jQuery.

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question