Answer the question
In order to leave comments, you need to log in
How to remove caching?
When you reload the page, the image is loaded the same every time. But if you check cache dissabled in devtool, then the pictures are different.
How to make so that the pictures were different in and without a check mark? I understand the problem is in the cache.
const getCat = () => {
const img = document.createElement('img');
img.classList.add('cat__img');
fetch('https://cataas.com/cat')
.then(response => response.blob())
.then(blob => {
img.src = URL.createObjectURL(blob);
});
return img
}
Answer the question
In order to leave comments, you need to log in
<script src="/socket.io/socket.io.js"></script>
here are the sockets
So at the beginning of the article, he installs npm install --save socket.io
And then connects<script src="/socket.io/socket.io.js"></script>
Disable cache via http headers
const options ={
headers: {
"Cache-Control":" no-cache",
"Pragma":" no-cache"
}
};
const getCat = () => {
const img = document.createElement('img');
img.classList.add('cat__img');
fetch('https://cataas.com/cat', options);
.then(response => response.blob())
.then(blob => {
img.src = URL.createObjectURL(blob);
});
return img
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question