Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So I'm a beginner and make a basic website hosted on github for just me and some friends to use time to time, but I occassionally push updates in terms of reliability and design improvements, but since github only hosts what's in your index.html and nothing else, there's no automated cache clearing and such, which is what you would see from say a prebuilt website with weebly.

How do I do this so that whenever I push an update we don't have to do CTRL + F5 to clear cache and reload page?

Doing this in an index.html file btw.

Thanks.

What I have tried:

Looked some solutions up online, all seem to be in a javascript or C++ environment..
Posted
Comments
j snooze 23-Feb-18 17:26pm    
what is being cached that you need refreshed? Do you have some javascript files that you change? Are you saying you only have the index.html file and you make html changes to it and those get cached? If its javascript files that's a pain point for most people and versioning the file seems to be what a lot of people do.
Member 13624114 23-Feb-18 17:27pm    
Basically it's the entire website. For example, changing links on buttons, swapping images on the icons of buttons, etc.

And basically it's just an index.html that gets cached, as whenever you load the page again, your browser just loads the cached version and not the actual website.

1 solution

Google for "html no cache header" and you'll find all you need.

You cannot clear the cache of the browser on page load. You can only control the caching policy of the page you send.
 
Share this answer
 
Comments
Member 13624114 23-Feb-18 19:50pm    
how would i do that for a button? I've got something similar to a clickable image.
(Example: The button)
Hide   Copy Code
<a href="Episode1/" class="myButton"><img src="Ep1.jpg" style="width:100%;height:100%;"> </a>


So it tells me to put
Hide   Copy Code
<META HTTP-EQUIV="Pragma" CONTENT="no-cache"><META HTTP-EQUIV="Expires" CONTENT="-1">

inside the header. Would I put this in between the two <a> and </a> tags? or would I put it within the I use to organize my content?
Dave Kreskowiak 23-Feb-18 20:05pm    
No, META tags ALWAYS go inside the HEAD tags at the top of your HTML page.

https://www.w3schools.com/tags/tag_meta.asp
Member 13624114 23-Feb-18 20:23pm    
So am I doing something wrong by not using HEAD tags? xd

EDIT: I'm wrong! Actually have been using a head Just I guess it was so insignificant I didn't remember making it!
Member 13624114 23-Feb-18 20:33pm    
OK so I just tried it, and it doesn't work. Here's my tag section of code:

<title>
I: The Phantom Menace

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">

In changing the title simply from "I: The Phantom Menace" to "TEST" and I had to CTRL Reload (Clear cache for the updates to apply.)

EDIT: For some reason, Codeproject is bugging out with the section of code. Here's a pastebin. https://pastebin.com/17pzxeTJ
Dave Kreskowiak 23-Feb-18 20:39pm    
It would appear that you put the META tags inside the TITLE tags, not the HEAD tags. Did you even go to the link I put in the previous post?

<html>
  <head>
    <meta HTTP-EQUIV="Pragma" CONTENT="no-cache" />
    <meta HTTP_EQUIV="Expires" CONTEXT="-1" />
  </head>
  <title>Something Blue</title>
<body>
</body>
</html>

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