CS0103: The name 'Caching' does not exist in the current context

We have a project for the WebGL platform on Unity version 2021.3.9 and want to move to version 2022.2.16.
The project works fine on 2021.3.x.
The same project on version 2022.2.16, in the Editor, works fine, but during the building of the WebGL build, the compiler says:
CS0103: The name ‘Caching’ does not exist in the current context

(of course, it is wrong, and Caching does exist)
What could be the issue?

(the similar question was asked a year ago here , but no answer)

I would recommend running additional tests:
2021.3.9 => try with 2021.3.23f1
2022.2.16 => try with 2022.2.0f1

By doing so, you can narrow down whether the issue appears when switching major/minor versions from 2021.3 to 2022.2. If so, you could consider staying on 2021.3. If either the 2021.3.23 tests fails with the same issue or 2022.2.0f1 does not fail, you can check the Unity changelog for versions that you haven’t tried to see if they contain any hints regarding changes that may make your build fail. You can also try to narrow down which version has that breaking change with the divide and conquer strategy.

I have more tips regarding Unity version upgrading on my blog.

Specifically simply comparing/diff-ing the ProjectSettings folder and its contents between the 2021.3 and 2022.2 versions may point you to a modified setting that could be causing the builds to fail. You could even make a copy of the 2021.3 project, then replace its ProjectSettings folder with the one from 2022.2 to see if that makes the build fail. By doing so you can confirm that it’s highly likely caused by a setting rather than Unity versions.

Before you try any of these more time-consuming searches for clues be sure to close the 2022.2 project and its IDE, then delete the Library folder (as well as others that are temporary such as Logs, obj, Temp) and re-open the project and try building again.

1 Like

Many thanks for your hints! I’ll try them out.

Ok, I’ve got an answer from the DevTeam:

After a further resolution with developers, we have decided that this issue is By Design due to the following reasons:
The Caching Scripting API is no longer supported on the Web platform as AssetBundles are cached in the browser cache in Unity 2022.1, and onwards.
This is also stated in the documentation.

The Script that uses the API should wrap it in an #ifdef to not execute it on the Web platform like so:

#if !UNITY_WEBGL
   UnityEngine.Caching.ClearOtherCachedVersions("anything", new Hash128());
#endif
3 Likes

Hello
We got same issue on Switch + Ps4 platform. I am using Unity 2021.3.28f. Is there anyway to clear cache on these platforms.