Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
terirutherford
916 PointsResponsive layouts not working in certain browsers
I'm running into problems when practicing with responsive layouts. My code is correct, however it won't load properly in Chrome or Firefox. I did read a tip on one of the class questions that said to clear the cache of the browsers, and that worked.
My questions are: 1) Why does this happen? 2) What is changing when I clear the cache to make the responsive codes run properly? 3) How can I keep this issue from reoccurring in the future?
Thanks!
3 Answers
eck
43,038 PointsBasically, the problem you are having is that you wrote some HTML and viewed it in a browser. That browser saved the html file locally on your computer (this is browser caching) so it could more efficiently open it if you returned to that page.
You then changed the file, but your browser was still opening the old version saved in the browser cache. So when you cleared the cache, you are deleting those saved files and your browser will retrieve the latest version.
One of the simplest solutions when testing and developing a web page to avoid your work from being cached is to use Chrome's incognito mode or Firefox's private window.
I hope this helps you understand the nature of the problem you encountered and how to work around it! ♥♥♥
Craig Watson
27,930 PointsHi Teri :)
What was the responsive code you were using i.e. flexbox etc. ?
Clearing the cache will just allow the browser to basically read the document freshly rather than use anything of memory it has from the last time it processed that code. (Very Broad Description)
Craig
terirutherford
916 Pointsthanks!
Zoltán Holik
3,401 PointsYour browser cache your css, javascript files because of faster webpage loading. There are a couple of ways to prevent this.
The simplest is:
- Use a PHP snippet like this:
<link href="/stylesheet.css?<?php echo time(); ?>" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/site-script.js?<?php echo time(); ?>"></script>
It's a very simple technique and doesn't affect your CSS or JavaScript code in any way.
terirutherford
916 PointsI'm assuming this goes in the <head>, is important in which order it goes?
eck
43,038 PointsThere are different requirements for running PHP files on your local machine than there is for HTML files. So, you will probably want to learn about PHP before using the above code.
Here is a PHP basics course on treehouse that would get you up to speed!
terirutherford
916 Pointsterirutherford
916 Pointsthank you!