# Caching problem when swapping between different sites?

**URL:** <https://discourse.gohugo.io/t/caching-problem-when-swapping-between-different-sites/5877>\
**Category:** support\
**Created:** [March 21, 2017, 9:05pm UTC](https://discourse.gohugo.io/t/caching-problem-when-swapping-between-different-sites/5877 "2017-03-21T21:05:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinmcbride](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/martinmcbride/32/2289_2.png) [@martinmcbride](https://discourse.gohugo.io/u/martinmcbride)\
**Post date:** [March 21, 2017, 9:05pm UTC](https://discourse.gohugo.io/t/caching-problem-when-swapping-between-different-sites/5877/1 "2017-03-21T21:05:29Z")

</div>

I am maintaining 3 different Hugo based sites, with slightly different themes. I use the built-in _hugo server_ command while developing and writing content.

Sometimes if I have been working on site A, then I change to site B, things aren’t quite right. It appears that the local server is picking up site A’s css files instead of the same named css for site B. The fault seems intermittent and usually corrects itself at some random point.

It always seems to be OK when I create the full site is the public folder, but it is a bit of a pain while I am creating content.

Is this a known problem, and is there a workaround?

---

<div class="post-metadata">

**Author:** ![budparr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/budparr/32/749_2.png) [@budparr](https://discourse.gohugo.io/u/budparr)\
**Post date:** [March 21, 2017, 9:29pm UTC](https://discourse.gohugo.io/t/caching-problem-when-swapping-between-different-sites/5877/2 "2017-03-21T21:29:11Z")

</div>

Just curious - (assuming are you using localhost:1313 for all of them), are you setting your browser to not cache anything?

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [March 21, 2017, 9:32pm UTC](https://discourse.gohugo.io/t/caching-problem-when-swapping-between-different-sites/5877/3 "2017-03-21T21:32:00Z")

</div>

> [@martinmcbride](#):
>
> Sometimes if I have been working on site A, then I change to site B, things aren’t quite right. It appears that the local server is picking up site A’s css files instead of the same named css for site B. The fault seems intermittent and usually corrects itself at some random point.

Also curious, are you pulling in any dynamic or “data-driven” content? For example, do you find that this eliminates the problem…

```auto
hugo server --ignoreCache

```

[https://hugodocs.info/templates/data-templates/#caching-of-urls](https://hugodocs.info/templates/data-templates/#caching-of-urls)

---

<div class="post-metadata">

**Author:** ![mattstratton](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mattstratton/32/24584_2.png) [@mattstratton](https://discourse.gohugo.io/u/mattstratton)\
**Post date:** [March 22, 2017, 8:43am UTC](https://discourse.gohugo.io/t/caching-problem-when-swapping-between-different-sites/5877/4 "2017-03-22T08:43:27Z")

</div>

What I usually do is set a different port for each project, which ensures that the same named css files, etc, don’t get cached under localhost.

you can use the `-p` flag on `hugo server` to set the port.

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [March 22, 2017, 6:40pm UTC](https://discourse.gohugo.io/t/caching-problem-when-swapping-between-different-sites/5877/5 "2017-03-22T18:40:03Z")

</div>

@mattstratton This is a much better solution than the one I proposed. I need to figure out where to put this in the new docs. Thanks!

---

<div class="post-metadata">

**Author:** ![budparr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/budparr/32/749_2.png) [@budparr](https://discourse.gohugo.io/u/budparr)\
**Post date:** [March 22, 2017, 7:24pm UTC](https://discourse.gohugo.io/t/caching-problem-when-swapping-between-different-sites/5877/6 "2017-03-22T19:24:34Z")

</div>

I’ll mention what I was going to say in case the thread goes stale.

I’m constantly switching back and forth between sites in development. I may use the port flag if I’m running more than one at a time (though, actually, the Hugo server does this for you automatically, even without the flag), but I’ve never seen this problem on localhost:1313 when running a fresh cache. I think the original poster’s issue is with browser cache.

So, the simplest answer is to run your localhost sites in a non-cached browser tab. So, for Chrome that’s Incognito/private mode, or, better yet, in the dev tools settings you can check “Disable cache (while DevTools is open)” and just “cmd-option i” and leave it in another window, which is handy anyway. Other browsers have similar settings.

FWIW, I also use Chrome Canary as my dev browser (Firefox has a dev browser, too), so it’s pretty seamless.

I hope that’s helpful. I think there’s plenty here to answer the question.

---

<div class="post-metadata">

**Author:** ![martinmcbride](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/martinmcbride/32/2289_2.png) [@martinmcbride](https://discourse.gohugo.io/u/martinmcbride)\
**Post date:** [March 22, 2017, 9:25pm UTC](https://discourse.gohugo.io/t/caching-problem-when-swapping-between-different-sites/5877/7 "2017-03-22T21:25:30Z")

</div>

Thanks, it looks like it probably is browser caching. I didn’t really make the connection that switching between different hugo sites would clash, but it is fairly obvious when it’s pointed out.

I will try using different ports for each project, I think that should fix it.

---

<div class="post-metadata">

**Author:** ![talves](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/talves/32/2062_2.png) [@talves](https://discourse.gohugo.io/u/talves)\
**Post date:** [April 10, 2017, 4:45pm UTC](https://discourse.gohugo.io/t/caching-problem-when-swapping-between-different-sites/5877/8 "2017-04-10T16:45:57Z")

</div>

I make sure to use different ports when working on localhost from site to site, but @budparr [recommendation](https://discuss.gohugo.io/t/caching-problem-when-swapping-between-different-sites/5877/6?u=budparr) is the real solution for the caching of Hugo development. Especially when you are using a javascript compiler on js assets.

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [May 8, 2017, 7:08pm UTC](https://discourse.gohugo.io/t/caching-problem-when-swapping-between-different-sites/5877/9 "2017-05-08T19:08:15Z")

</div>

I just came across the caching issue myself. I tested a different icon font for one of my projects and then when I reverted back to the original, the icons weren’t displaying at all `--ignoreCache` didn’t help. Using an incognito tab solved it.
