{"record":{"id":"46634896ae1a183c","repo":"Semantic-Org/Semantic-UI","slug":"caching-responses-locally-requires-session-storage","errorCode":null,"errorMessage":"Caching responses locally requires session storage","messagePattern":"Caching responses locally requires session storage","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/definitions/behaviors/api.js","lineNumber":1137,"sourceCode":"\n  // request aborted\n  onAbort     : function(errorMessage, $module) {},\n\n  successTest : false,\n\n  // errors\n  error : {\n    beforeSend        : 'The before send function has aborted the request',\n    error             : 'There was an error with your request',\n    exitConditions    : 'API Request Aborted. Exit conditions met',\n    JSONParse         : 'JSON could not be parsed during error handling',\n    legacyParameters  : 'You are using legacy API success callback names',\n    method            : 'The method you called is not defined',\n    missingAction     : 'API action used but no url was defined',\n    missingSerialize  : 'jquery-serialize-object is required to add form data to an existing data object',\n    missingURL        : 'No URL specified for api event',\n    noReturnedValue   : 'The beforeSend callback must return a settings object, beforeSend ignored.',\n    noStorage         : 'Caching responses locally requires session storage',\n    parseError        : 'There was an error parsing your request',\n    requiredParameter : 'Missing a required URL parameter: ',\n    statusMessage     : 'Server gave an error: ',\n    timeout           : 'Your request timed out'\n  },\n\n  regExp  : {\n    required : /\\{\\$*[A-z0-9]+\\}/g,\n    optional : /\\{\\/\\$*[A-z0-9]+\\}/g,\n  },\n\n  className: {\n    loading : 'loading',\n    error   : 'error'\n  },\n\n  selector: {\n    disabled : '.disabled',","sourceCodeStart":1119,"sourceCodeEnd":1155,"githubUrl":"https://github.com/Semantic-Org/Semantic-UI/blob/597843ab84d565cccfd8fd7719416350ae73e734/src/definitions/behaviors/api.js#L1119-L1155","documentation":"This error is logged by the API module's read.cachedResponse() (api.js:144-146) and write.cachedResponse() (api.js:160-162) functions when settings.cache is set to 'local' (requesting sessionStorage-based caching) but window.Storage is undefined. window.Storage is the browser's built-in interface for sessionStorage and localStorage; if it is unavailable, the module cannot cache or retrieve responses locally.","triggerScenarios":"Configuring $('.el').api({ cache: 'local' }) in an environment where sessionStorage is not available. This occurs in private/incognito browsing modes in some older browsers, in Safari when cookies/storage are blocked, in embedded contexts (iframes with sandbox restrictions), or in server-side rendering environments where window and sessionStorage do not exist.","commonSituations":"Older browsers (IE7 and below) that lack sessionStorage. Safari with cross-site tracking prevention blocking storage in iframes. Headless browser testing environments (some configurations). Content Security Policy or sandbox attributes restricting storage access. Private browsing modes in mobile browsers.","solutions":["Use a different cache strategy: set settings.cache to false or 'browser' (relies on HTTP cache headers instead of sessionStorage).","Wrap sessionStorage usage in a feature detection check before enabling cache: 'local'.","Implement a fallback cache mechanism (e.g., in-memory Map) when sessionStorage is unavailable."],"exampleFix":"// before\n$('.el').api({\n  url: '/api/data',\n  cache: 'local'\n  // fails in private browsing or sandboxed iframes\n});\n\n// after\nvar canCache = (function() {\n  try { return window.Storage !== undefined; } catch(e) { return false; }\n})();\n$('.el').api({\n  url: '/api/data',\n  cache: canCache ? 'local' : false\n});","handlingStrategy":"validation","validationCode":"// Feature-detect sessionStorage before enabling local cache\nvar storageAvailable = (function() {\n  try {\n    var t = '__test__';\n    sessionStorage.setItem(t, t);\n    sessionStorage.removeItem(t);\n    return true;\n  } catch(e) { return false; }\n})();\n$('.el').api({\n  cache: storageAvailable ? 'local' : false,\n  url: '/api/data'\n});","typeGuard":"// Check if sessionStorage is accessible\nfunction isSessionStorageAvailable() {\n  try { return window.Storage !== undefined && !!window.sessionStorage; }\n  catch(e) { return false; }\n}","tryCatchPattern":null,"preventionTips":["Always feature-detect sessionStorage before enabling cache: 'local'.","Provide a graceful degradation path (e.g., in-memory cache) for environments without storage.","Test in private/incognito browsing modes where storage may be restricted."],"tags":["api","cache","session-storage","browser-support","semantic-ui"],"backgroundTag":null,"analyzedSha":"597843ab84d565cccfd8fd7719416350ae73e734","analyzedAt":"2026-08-13T01:44:23.827Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}