2012-05-15 5 views
3

저는 LESS CSS (더 정확하게는 less.js)를 사용하고 있는데, 이는 LocalStorage를 악용하는 것으로 보입니다. 내 응용 프로그램을 로컬에서 실행하는 동안 전에 이런 실수를 한 번도 본 적이 없었지만, 이제는 모든 페이지 표시에서 "영구 저장 최대 크기에 도달했습니다"링크 바로 위에 내 앱의 .less 파일이 있습니다.CSS 및 로컬 스토리지 문제가 덜

이것은 Firefox 12.0에서만 발생합니다.

이 문제를 해결할 방법이 있습니까?

PS :

"use strict"; 
var LocalStorageChecker = Class.create({ 
    testDummyKey: "__DUMMY_DATA_KEY__", 
    maxIterations: 100, 
    logger: new Logger("LocalStorageChecker"), 
    analyzeStorage: function() { 
     var result = false; 
     if (Modernizr.localstorage && this._isLimitReached()) { 
      this._clear(); 
     } 
     return result; 
    }, 
    _isLimitReached: function() { 
     var localStorage = window.localStorage; 
     var count = 0; 
     var limitIsReached = false; 
     do { 
      try { 
       var previousEntry = localStorage.getItem(this.testDummyKey); 
       var entry = (previousEntry == null ? "" : previousEntry) + "m"; 
       localStorage.setItem(this.testDummyKey, entry); 
      } 
      catch(e) { 
       this.logger.debug("Limit exceeded after " + count + " iteration(s)"); 
       limitIsReached = true; 
      } 
     } 
     while(!limitIsReached && count++ < this.maxIterations); 
     localStorage.removeItem(this.testDummyKey); 
     return limitIsReached; 
    }, 
    _clear: function() { 
     try { 
      var localStorage = window.localStorage; 
      localStorage.clear(); 
      this.logger.debug("Storage clear successfully performed"); 
     } 
     catch(e) { 
      this.logger.error("An error occurred during storage clear: "); 
      this.logger.error(e); 
     } 
    } 
}); 


document.observe("dom:loaded",function() { 
    var checker = new LocalStorageChecker(); 
    checker.analyzeStorage(); 
}); 
: 주로 Calculating usage of localStorage space 영감이 내가 (이 프로토 타입을 기반으로 사용자 정의 사소한 Logger 클래스에 따라 다르지만이 쉽게 환경에 적응해야한다)하고 결국 무엇인가

PPS : UI에 대한 성능 영향을 아직 측정하지 못했지만 데코레이터를 생성하고 X 분마다 만 저장소 테스트를 수행 할 수 있습니다 (예 : 로컬 저장소에서 마지막으로 실행 한 타임 스탬프 포함).

답변

1

다음은 실행중인 오류에 대한 유용한 리소스입니다.

http://www.sitepoint.com/building-web-pages-with-local-storage/#fbid=5fFWRXrnKjZ

너무 많은 공간이있는 경우에만 로컬 스토리지 통찰력을 제공하고 각 브라우저에서 할 수 있습니다 최대 그것을 밖으로. 문제를 해결하려면 localstorage에서 일부 데이터를 제거하십시오.

+0

xx 이것은 올바른 방향으로 나를 가리켰습니다. – Rolf

1

Less.js는 @imported 인 콘텐츠를 지속적으로 캐시합니다. 이 스크립트를 사용하여 캐시 된 내용을 지울 수 있습니다. 아래 스크립트를 사용하면 destroyLessCache ('/ path/to/css /') 함수를 호출 할 수 있으며 캐시 된 css 파일의 localStorage가 지워집니다.

function destroyLessCache(pathToCss) { // e.g. '/css/' or '/stylesheets/' 
     if (!window.localStorage || !less || less.env !== 'development') { 
      return; 
     } 
     var host = window.location.host; 
     var protocol = window.location.protocol; 
     var keyPrefix = protocol + '//' + host + pathToCss; 
     for (var key in window.localStorage) { 
      if (key.indexOf(keyPrefix) === 0) { 
      delete window.localStorage[key]; 
      } 
     } 
    } 
+0

괜찮습니다. 실제로 병이 실제로 비슷합니다. – Rolf

+0

어떻게 진행되는지 알려주세요. – retornam

+0

방금 ​​쓴 해결책으로 내 질문을 편집했습니다. – Rolf

관련 문제