JCHASE11
JCHASE11

Reputation: 3941

Old content appearing on site. Auto Clear Cache?

I have a website that is updated regularly and I am having a problem where old content is showing up on the page. It can be fixed by refreshing a few times or clearing the cache. I am looking for a solution so no data is stored on the PC and the site is forced to refresh each time. Perhaps an auto cache clear plugin or something of the like? Any ideas?

Upvotes: 2

Views: 20057

Answers (4)

christmex
christmex

Reputation: 121

I suggest you try this one, I use this way when my code is still on the local

<link rel="stylesheet" href="styel.css?v=<?= time(); ?>">

but when you're ready for production mode, put the latest version of your CSS, or whatever you want like ?v=1.1

hope it will help you

Upvotes: 0

n8wrl
n8wrl

Reputation: 19765

This may sound like a good idea at first but how many users do you hope to support in the future?

I ask because if every request should be completely refreshed every time you are going to have a LOT of traffic on your web server. And, your users are going to start complaining about page load times.

With help from tools like yslow and firebug, we've tried to analyze the portions of our pages that can be cached and those that can't. Tip of the iceburg, but...

Images to support site layout - backgrounds, buttons, etc. should be cached for a very long time. They go in a folder tree flagged by IIS as cachable for a long time. They could be delivered by a CDN long-term. If these have to change, we upload new files with new names.

Script/CSS and other, possibly-changing content goes in another folder that gets a shorter cache duration. This could be a problem if we have to fix bugs, but again, upload a new file with a new name if necessary.

Anything data-driven (our app is a catalog) is localized and gets refreshed every time.

This is still a work-in-progress for us, but we're seeing MUCH less server traffic and MUCH faster page load times.

I hope this helps!

Upvotes: 4

Che
Che

Reputation: 31

use this, my son

<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0">

Upvotes: 3

Chris Thompson
Chris Thompson

Reputation: 35598

Try putting this in your head tags

<meta http-equiv="cache-control" content="no-cache">

Edit Just a note, this doesn't force the browser not to cache it, but most browsers will listen

Upvotes: 2

Related Questions