diff --git a/.licenses/npm/@actions/cache.dep.yml b/.licenses/npm/@actions/cache.dep.yml
index c2d23e2e..35b0a4bf 100644
--- a/.licenses/npm/@actions/cache.dep.yml
+++ b/.licenses/npm/@actions/cache.dep.yml
@@ -1,6 +1,6 @@
 ---
 name: "@actions/cache"
-version: 1.0.8
+version: 2.0.0
 type: npm
 summary: Actions cache lib
 homepage: https://github.com/actions/toolkit/tree/main/packages/cache
diff --git a/dist/setup/index.js b/dist/setup/index.js
index 75c4b794..e449da6f 100644
--- a/dist/setup/index.js
+++ b/dist/setup/index.js
@@ -5597,7 +5597,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
     return (mod && mod.__esModule) ? mod : { "default": mod };
 };
 Object.defineProperty(exports, "__esModule", { value: true });
-exports.isGhes = exports.validatePythonVersionFormatForPyPy = exports.writeExactPyPyVersionFile = exports.readExactPyPyVersionFile = exports.getPyPyVersionFromPath = exports.isNightlyKeyword = exports.validateVersion = exports.createSymlinkInFolder = exports.WINDOWS_PLATFORMS = exports.WINDOWS_ARCHS = exports.IS_LINUX = exports.IS_WINDOWS = void 0;
+exports.isCacheFeatureAvailable = exports.isGhes = exports.validatePythonVersionFormatForPyPy = exports.writeExactPyPyVersionFile = exports.readExactPyPyVersionFile = exports.getPyPyVersionFromPath = exports.isNightlyKeyword = exports.validateVersion = exports.createSymlinkInFolder = exports.WINDOWS_PLATFORMS = exports.WINDOWS_ARCHS = exports.IS_LINUX = exports.IS_WINDOWS = void 0;
+const cache = __importStar(__webpack_require__(692));
 const fs_1 = __importDefault(__webpack_require__(747));
 const path = __importStar(__webpack_require__(622));
 const semver = __importStar(__webpack_require__(876));
@@ -5671,6 +5672,18 @@ function isGhes() {
     return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
 }
 exports.isGhes = isGhes;
+function isCacheFeatureAvailable() {
+    if (!cache.isFeatureAvailable()) {
+        if (isGhes()) {
+            throw new Error('Caching is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.');
+        }
+        else {
+            throw new Error('An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.');
+        }
+    }
+    return true;
+}
+exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
 
 
 /***/ }),
@@ -6045,7 +6058,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
     });
 };
 Object.defineProperty(exports, "__esModule", { value: true });
-const actionsCache = __importStar(__webpack_require__(692));
 const core = __importStar(__webpack_require__(470));
 const finder = __importStar(__webpack_require__(927));
 const finderPyPy = __importStar(__webpack_require__(847));
@@ -6058,14 +6070,6 @@ function isPyPyVersion(versionSpec) {
 }
 function cacheDependencies(cache, pythonVersion) {
     return __awaiter(this, void 0, void 0, function* () {
-        if (!actionsCache.isFeatureAvailable()) {
-            if (utils_1.isGhes()) {
-                throw new Error('Caching is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.');
-            }
-            else {
-                throw new Error('An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.');
-            }
-        }
         const cacheDependencyPath = core.getInput('cache-dependency-path') || undefined;
         const cacheDistributor = cache_factory_1.getCacheDistributor(cache, pythonVersion, cacheDependencyPath);
         yield cacheDistributor.restoreCache();
@@ -6089,7 +6093,7 @@ function run() {
                     core.info(`Successfully setup ${installed.impl} (${pythonVersion})`);
                 }
                 const cache = core.getInput('cache');
-                if (cache) {
+                if (cache && utils_1.isCacheFeatureAvailable()) {
                     yield cacheDependencies(cache, pythonVersion);
                 }
             }
diff --git a/src/setup-python.ts b/src/setup-python.ts
index f3bb2d49..2f946578 100644
--- a/src/setup-python.ts
+++ b/src/setup-python.ts
@@ -1,28 +1,16 @@
-import * as actionsCache from '@actions/cache';
 import * as core from '@actions/core';
 import * as finder from './find-python';
 import * as finderPyPy from './find-pypy';
 import * as path from 'path';
 import * as os from 'os';
 import {getCacheDistributor} from './cache-distributions/cache-factory';
-import {isGhes} from './utils';
+import {isCacheFeatureAvailable} from './utils';
 
 function isPyPyVersion(versionSpec: string) {
   return versionSpec.startsWith('pypy-');
 }
 
 async function cacheDependencies(cache: string, pythonVersion: string) {
-  if (!actionsCache.isFeatureAvailable()) {
-    if (isGhes()) {
-      throw new Error(
-        'Caching is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'
-      );
-    } else {
-      throw new Error(
-        'An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.'
-      );
-    }
-  }
   const cacheDependencyPath =
     core.getInput('cache-dependency-path') || undefined;
   const cacheDistributor = getCacheDistributor(
@@ -52,7 +40,7 @@ async function run() {
       }
 
       const cache = core.getInput('cache');
-      if (cache) {
+      if (cache && isCacheFeatureAvailable()) {
         await cacheDependencies(cache, pythonVersion);
       }
     }
diff --git a/src/utils.ts b/src/utils.ts
index fc2be06d..8f9b75f9 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -1,3 +1,4 @@
+import * as cache from '@actions/cache';
 import fs from 'fs';
 import * as path from 'path';
 import * as semver from 'semver';
@@ -99,3 +100,19 @@ export function isGhes(): boolean {
   );
   return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
 }
+
+export function isCacheFeatureAvailable(): boolean {
+  if (!cache.isFeatureAvailable()) {
+    if (isGhes()) {
+      throw new Error(
+        'Caching is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'
+      );
+    } else {
+      throw new Error(
+        'An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.'
+      );
+    }
+  }
+
+  return true;
+}