Having trouble clearing cache to refresh webpage - html

This may sound like a very basic question but I feel like I've tried everything.
This a follow-up to this post I made earlier, where I resolved the issue, only for it to come back again.
To summarize, I was making some change to the contact.css file on the contact page of my website when I noticed the changes were working offline but didn't appear online. I narrowed this issue down to a caching issue with the above post (others could see the changes but I couldn't).
In the above example I couldn't get my website to show up as background-color:blue - eventually it worked and I thought I'd fixed it... So I go to change the color back to normal and boom, it stops refreshing the changes again.
So I think it's some sort of caching issue but for the life of me I can't get my cache to clear properly so that I can refresh and see the changes.
Here are the things I have tried already:
Clearing cache (many times) on Chrome, Firefox, and Opera
Hard refresh on Chrome, Firefox, and Opera
Disabling cache through dev tools on Chrome and Firefox (this worked initially then stopped working when I re-updated the website)
Checked multiple times that the CSS file uploaded correctly and the file path was correct. This was confirmed because the correct changes were seen by other people.
Flushed my DNS
Changed from my ISPs DNS to google's 8.8.8.8 + 8.8.4.4
I'm using HostGator to host my website, I'm wondering at this point whether it's something to do with them? I really just have no idea at this point.
Here's what I see online:
Here's what I should be seeing and what I do see on the offline version of my website:

I noticed you said "I'd really like to get to the bottom of the underlying issue" so I figured I'd write an answer to provide a few options (and if anyone wants me to add others, please feel free to add a comment). Overall though, determining your root cause is likely much harder than just solving your overall problem, but let's start with possible causes that I can think of off my head:
Multiple CDN servers taking a while to update so some are returning the old data (your current session) and some are returning new (incognito)
Server session caching so when you reload the page within one http context session you get back the same content (I've seen this in product search queries for example)
The solution to this is relatively simple though, it's called cache busting. Basically, every time you update your source code just add a unique key in either the query string, file name or something to make the url unique. For example, for your css you can link https://path/to.css?v2.0.1 and just keep increasing the version number as you go. If you use webpack for your build outputs, they have a content hash variable that you can use as a token in the file names.
As for the CDNs possibly caching things out of date... the content hash solution will solve that problem as it's an entirely different file name so the CDN will go get it from the root if it doesn't have it in it's cache. I'm unsure of the url version query parameter will do the same, maybe someone else could shed some light on that.

Have you tried using Incognito in Chrome?

Related

Utterly confused. css not modifying html

I have no idea what is happening. I don't even know what information would be relevant, so please ask me anything you think could be related. The problem: I write a html script and css to modify it. I put the files on my webserver (Apache2 running on Ubuntu 22.04) and they work perfectly. I can modify the css script (e.g. changing font sizes, margins etc.) and the changes show up on the corresponding html. Yet, if I leave the laptop alone for an hour or so (not changing a thing), and I modify the css script it has zero effect on the corresponding html. It's as if no changes have been made. I can delete the files, write them over again and they work fine; leave it alone for a period of time and it no longer works. This holds true for all my html/css files. All help is greatly appreciated. Thanks.
I tried restarting Apache, restarting the laptop, rewriting the files, renaming the files, moving the files. No matter what I do, after a period I can no longer modify the html with css.
The first step would be to identify the source of the issue. This can be done by checking the Apache server error logs, as well as any other relevant logs from the Ubuntu OS. The error logs may help identify the root cause of the problem, such as a configuration issue or a software bug.
Once the source of the issue is identified, the next step is to attempt to troubleshoot the problem. This could include checking the web server's configuration, ensuring the correct permissions are set for the HTML and CSS files, and ensuring the server has the correct modules installed to support HTML and CSS.
Additionally, it may be helpful to check the browser's cache to ensure the HTML and CSS files are being served correctly, as a cached version of the page may be loading instead of the updated version.
Finally, it could be helpful to test the same setup with a different web server, such as Nginx, to determine if the issue is with the server or something else.
Ultimately, the devil in the details may be something as simple as a configuration issue or a software bug, or it may be something more complex such as an issue with the browser's cache. Identifying the root cause of the issue will be key to resolving the problem.

Html changes are not updating in chrome only

So there is some kind of caching issue going on with chrome lately.
I updated an image on a web page, but it will not update in chrome. Other browsers are fine.
Also I'm going to note that I changed the html, and gave the image a new name to force browsers to grab the updated version.
i.e image.jpg > image-v1.jpeg
How on earth does chrome not grab the updated version of this?
Anyone seen this going on lately and know of a fix.
Thanks
When you clear browsing data, make sure to check the box to clear cached images, also make sure the duration is set to "All time".
https://i.ibb.co/jzYk6DK/ex.png
If that doesn't work, try renaming the image.
If that also doesn't work, take a look at the web server configuration expiry headers, and check the duration for cached images in your format. It could be in .htaccess, or it could be elsewhere depending on if you're using apache2 or Nginx.
For anyone stumped on this kind of an issue, if you are using a web farm check to make sure DFS replication across the servers is working correctly.
It was failing for one server in my case, this is why some users got the updated version while others didn't.
to verify if replication worked, log into the servers via RDP then check the last modified date time stamps for the file(s) in question.

Chrome is not clearing cache

I am working on a new site and whenever I change CSS settings chrome will not accept those changes unless I close out of chrome completely with Task manager and relaunch it. I have a tried quite a few things. Below is a list of things I've tried:
Versioning the CSS file (I am using a PHP date stamp at the end of the CSS file
Enabling "Clear Cache while developer window is open" in the Developer console
Using Ctrl + F5 to clear cache on refresh
Going to Application and Clear Storage in the developer Console
Clearing Cache folder in local AppData
Deleting CSS file from stie, refreshing, and readding file.
Incognito mode
Adding Launch options to chrome shortcut --disk-cache-dir=null
Adding Browser Plugins to delete cache.
Anyone have any ideas how to help? It is extremely annoying and inefficient to close chrome every time I want to check a CSS change. Another annoyance is that I am trying to listen to music in the browser so if I close chrome I have to go back and get my music playing again and it's just as of now extremely annoying and way more time consuming than I want.
I've tried looking at other articles online about cache busting and other articles on Stack Overflow but I've tried to do most of what they suggest and I haven't seen any positive outcome yet. Most articles say to add some sort of random string or version on the end of the CSS file as a GET request but that isn't working though I know that has worked for me in the past.
pres f12 > f1 > network > disable cache (while DevTools is open). This should solve your problem
Development server was running various caching tools though they should have been turned off. After disabling them chrome started to work better and most of the time CTRL+F5 did the trick.
"clearing cache" is not as easy as it should be. Instead of clearing cache on my browsers, I realized that "touching" the server files cached will actually change the date and time of the source file cached on the server (Tested on Edge, Chrome and Firefox) and most browsers will automatically download the most current fresh copy of whats on your server (code, graphics any multimedia too). I suggest you just copy the most current scripts on the server and "do the touch thing" solution before your program runs, so it will change the date of all your problem files to a most current date and time, then it downloads a fresh copy to your browser:
<?php
touch('/www/sample/file1.css');
touch('/www/sample/file2.css');
touch('/www/sample/file2.css');
?>
then ... the rest of your program...
It took me some time to resolve this issue (as many browsers act differently to different commands, but they all check time of files and compare to your downloaded copy in your browser, if different date and time, will do the refresh), If you can't go the supposed right way, there is always another usable and better solution to it. Best Regards and happy camping. By the way touch(); or alternatives work in many programming languages inclusive in javascript bash sh php and you can include or call them in html.
I used to have the same problem, and I believe it's a (pretty annoying) bug with chrome. You can use the CSS Reloader Chrome Extension to solve it. Not ideal, but better
If you are trying out new CSS updates, I suggest using Chrome's "Inspect" function to dynamically update CSS settings and observe the results interactively. This may save some time during update cycles as compared to manual edits alone.
Another option to try is to define "cache-control" meta tags in your head section. For development/testing, you may want to have no caching. For a real website, you may want to have a shorter age limit. Refer to the following SO Q&A.
Using meta tags to turn of caching in all browsers?

Debugging why the HTML Cache isn't working

I was wondering if anybody could direct me to any tools for debugging the cache.manifest file in offline HTML5 access. I recently downloaded a program called Manifesto which allows me to look up the cache manifest on loading a page. Everything seems to working fine however it keeps on saying that the status is "uncached". Obviously, it seems like although it is checking to make sure the cache files are there, it isn't actually caching them upon load. Whats going on and more importantly, how do I figure out how to solve it?
I got it to work. To be honest, it might have been working before but because I was having some different php scripts running in the background I had to be a little careful with pulling it up.

1 page served from 2 different servers looks different in 1 browser -- beyond weird

This is a prize winner.
I have Apache on my PC and on my remote server.
I have a page that has been a real nuisance to get looking right in both IE (IE7) and FireFox (FF3.0). At the moment it is close enough in the two browsers to live with.
Here's the crazy part. When I look at the page as served by my localhost server and as served by my production remote host server it looks just a little different. The differences all look like matters of margins and/or placement and/or image size.
It doesn't matter whether it is IE or FF. I get 2 close but not identical renderings on IE and the same on FF.
I've done all the basic commonsense trouble shooting I can think of. I've repeated the FTP transfer several times and checked all the file permissions. I've even downloaded the CSS files into the browsers directly just to make sure they still look the same.
By any principles I can think of, what I am seeing SHOULD be impossible. I can't think of anything that would account for this completely bizarre effect.
i'd be very much obliged if you have any thoughts on the subject.
Thanks for reading.
It could be that you actually do not see the version you uploaded to the server but a cached one. (servers cache, your local cache, isp's cache...)
You can try to save the page and the css you get from both, the server and your local machine, and then compare it. I would use a diff tool like tkdiff. Then you know if there are differences in the markup.
When you've downloaded both versions to a local directory you can also check the differences in the browser again. Is it still there?
You can also instruct apache to send the page with the headers "no cache". Then all caching is disabled. The keyword to look for is "cache-control" here. There are many ways to send this information in the headers. (But note: you should not disable caching on a live system as it will slow down the whole thing...)
Tatu Ulmanen & Pekka -- My enthusiastic thanks.
You were right.
a) The content types were, as one would expect identical -- but I hadn't thought of checking it, so thanks for that.
b) Pekka gets the cigar. The browser zoom setting had been altered from window to window in the rush of work, and this made a noticable difference in the layouts -- as one would expect.
Frankly I doubt I would have thought to check that. Ironic no?
May luck smile upon you both.