Is there a simple way do prevent all caching when testing the appearance of changes to the site? I use WP Super Cache. I can delete its cache using the option provided, delete the cache for my browser, and still some changes to css or widgets do not refresh. I try other work-arounds like switching browsers or computers, but there must be a more stream-lined workflow where I can ensure I'm viewing the changes I made and not some cached earlier format? What's the best solution for this?
|
|
Add the
Result:
|
|||||||||||
|
|
This might seem overly simple, but how about just disabling caching until you're done with the development portion of your site? It's more than simple to turn on and off. |
|||||||||||
|
|
I know that this question has had an answer accepted, but I think that that answer is still too complicated for the problem at hand, and may actually be incorrect depending on the user (no offense though), so I thought I'd still share how I bypass caching when I do my dev (not just with Wordpress). Most modern browsers have something called incognito mode. In this mode, nothing in your computer is cached, so every refresh is a fresh slate download off the server. In Internet Explorer you press If your browser doesn't have incognito mode, you can normally force a hard reload by pressing As for your question regarding the CSS files (and essentially, all your asset files, like images and Javascript files), those aren't cached in any way by WP Super Cache. Your settings and/or use of this plugin does not affect how those files are served. What's caching those files are your browser, and that's the reason why you do a hard reload. What the plugin does is it evaluates how Wordpress builds your HTML files (via PHP), and stores a copy, so that the next time someone requests the same post, page, or whatever, it serves the copy, and won't have to reevaluate the PHP-generated HTML again, and therefore save some computing time, loading your pages that much quicker. (I hope that's clear.) The problem with that is, if you're slapping on a timestamp on your CSS files' URL via a PHP function, that is a PHP evaluation to HTML, and that will be cached by WP Super Cache. Every request to the same post will have the same timestamp because users are being served a copy of the original timestamp evaluation. (Correct me if I'm wrong.) The correct way to bypass WP Super Cache's caching is to set the option Finally (and this is a personal preference, as I'm a real stickler when it comes to coding), resorting to the use of incognito or forced hard reloads won't require you to add unnecessary markup on your HTML pages. Of course, adding a timestamp only adds about 13 bytes per static file per request, but hey, like I said, I'm a stickler for this kind of stuff. It's still 13 bytes unnecessary. |
|||
|
|
HyperCache disables caching when you're logged in as an admin. Not sure whether WP Super Cache has the same functionality. |
|||
|
|
|
Gosh, many ways to answer this one! First and foremost, you asked about two different things: WP Super Cache and CSS files. These are cached differently, in different places, so it's important to recognize where your problem is. If WP Super Cache, you can define the constant
Each site also has a unique key to append to the URL to load a fresh version of the page, which you can find in the "Advanced" tab, I believe. Breaking it down to an even better solution, you should consider setting up a development environment and a production environment, where your development environment doesn't have WP Super Cache enabled (again, assuming that's your problem). If your issue is with CSS/JS files, then see the answer by toscho and subsequent comment by m0r7if3r above. |
|||
|
|
|
If you're using Chrome (which I highly suggest), open Inspector, click the settings icon in the lower right corner, and under "Network" select "Disable Cache." |
|||
|
|
|
The Versions plugin takes care of this headache autimatically. Fixes version numbers for stylesheets and scripts automatically. WordPress plugin Versions. Works really good. |
|||||
|