diff --git a/jac/base.py b/jac/base.py
index aab7298..8dc9708 100644
--- a/jac/base.py
+++ b/jac/base.py
@@ -49,7 +49,7 @@ class Compressor(object):
             ),
         )
 
-        if os.path.exists(cached_file):
+        if not self.config.compressor_debug and os.path.exists(cached_file):
             filename = os.path.join(
                 u(self.config.compressor_static_prefix),
                 os.path.basename(cached_file),
@@ -79,13 +79,6 @@ class Compressor(object):
                 msg = u('Unsupported type of compression {0}').format(mimetype)
                 raise RuntimeError(msg)
 
-            text = self.get_contents(text)
-            compressed = compressor.compile(text,
-                                            mimetype=mimetype,
-                                            cwd=cwd,
-                                            uri_cwd=uri_cwd,
-                                            debug=self.config.compressor_debug)
-
             if not self.config.compressor_debug:
                 outfile = cached_file
             else:
@@ -98,14 +91,27 @@ class Compressor(object):
                     ),
                 )
 
-            if assets.get(outfile) is None:
-                assets[outfile] = u('')
-            assets[outfile] += u("\n") + compressed
+            if os.path.exists(outfile):
+                assets[outfile] = None
+                continue
+
+            text = self.get_contents(text)
+            compressed = compressor.compile(text,
+                                            mimetype=mimetype,
+                                            cwd=cwd,
+                                            uri_cwd=uri_cwd,
+                                            debug=self.config.compressor_debug)
+
+            if not os.path.exists(outfile):
+                if assets.get(outfile) is None:
+                    assets[outfile] = u('')
+                assets[outfile] += u("\n") + compressed
 
         blocks = u('')
         for outfile, asset in assets.items():
-            with open(outfile, 'w', encoding='utf-8') as fh:
-                fh.write(asset)
+            if not os.path.exists(outfile):
+                with open(outfile, 'w', encoding='utf-8') as fh:
+                    fh.write(asset)
             filename = os.path.join(
                 u(self.config.compressor_static_prefix),
                 os.path.basename(outfile),
diff --git a/jac/contrib/flask.py b/jac/contrib/flask.py
index 7111d19..4c53060 100644
--- a/jac/contrib/flask.py
+++ b/jac/contrib/flask.py
@@ -84,8 +84,8 @@ class JAC(object):
         app.jinja_env.compressor_offline_compress = app.config.get('COMPRESSOR_OFFLINE_COMPRESS', False)
         app.jinja_env.compressor_follow_symlinks = app.config.get('COMPRESSOR_FOLLOW_SYMLINKS', False)
         app.jinja_env.compressor_debug = app.config.get('COMPRESSOR_DEBUG', False)
-        app.jinja_env.compressor_output_dir = app.config.get('COMPRESSOR_OUTPUT_DIR') or app.static_folder
-        app.jinja_env.compressor_static_prefix = app.config.get('COMPRESSOR_STATIC_PREFIX') or app.static_url_path
+        app.jinja_env.compressor_output_dir = app.config.get('COMPRESSOR_OUTPUT_DIR') or os.path.join(app.static_folder, 'sdist')
+        app.jinja_env.compressor_static_prefix = app.config.get('COMPRESSOR_STATIC_PREFIX') or app.static_url_path + '/sdist'
         app.jinja_env.compressor_classes = app.config.get('COMPRESSOR_CLASSES', {
             'text/css': LessCompressor,
             'text/coffeescript': CoffeeScriptCompressor,

This tool is too slow, how to improve？
diff --git a/tests/contrib/test_flask.py b/tests/contrib/test_flask.py
index 6bf6bbe..0c11cdd 100644
--- a/tests/contrib/test_flask.py
+++ b/tests/contrib/test_flask.py
@@ -22,20 +22,24 @@ def test_flask_extension_jinja_env_add_extension(mocked_flask_app):
 
 def test_flask_extension_jinja_env_compressor_output_dir(mocked_flask_app):
     mocked_flask_app.static_folder = '/static/folder'
+    mocked_flask_app.static_url_path = '/static'
     mocked_flask_app.config = dict()
 
     ext = JAC()
     ext.init_app(mocked_flask_app)
-    assert mocked_flask_app.jinja_env.compressor_output_dir == '/static/folder'
+    assert mocked_flask_app.jinja_env.compressor_output_dir == '/static/folder/sdist'
+    assert mocked_flask_app.jinja_env.compressor_static_prefix == '/static/sdist'
 
 
 def test_flask_extension_jinja_env_static_prefix(mocked_flask_app):
+    mocked_flask_app.static_folder = '/static/folder'
     mocked_flask_app.static_url_path = '/static-url'
     mocked_flask_app.config = dict()
 
     ext = JAC()
     ext.init_app(mocked_flask_app)
-    assert mocked_flask_app.jinja_env.compressor_static_prefix == '/static-url'
+    assert mocked_flask_app.jinja_env.compressor_output_dir == '/static/folder/sdist'
+    assert mocked_flask_app.jinja_env.compressor_static_prefix == '/static-url/sdist'
 
 
 def test_flask_extension_jinja_env_source_dirs(mocked_flask_app):

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest mock
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
beautifulsoup4==4.5.1
exceptiongroup==1.2.2
iniconfig==2.1.0
-e git+https://github.com/jaysonsantos/jinja-assets-compressor.git@13dd55cecae3f0ca16b9a52a59be5087c0bf9f36#egg=jac
Jinja2==3.1.6
MarkupSafe==3.0.2
mock==5.2.0
ordereddict==1.1
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
rjsmin==1.0.12
six==1.10.0
tomli==2.2.1

name: jinja-assets-compressor
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - beautifulsoup4==4.5.1
      - exceptiongroup==1.2.2
      - iniconfig==2.1.0
      - jinja2==3.1.6
      - markupsafe==3.0.2
      - mock==5.2.0
      - ordereddict==1.1
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - rjsmin==1.0.12
      - six==1.10.0
      - tomli==2.2.1
prefix: /opt/conda/envs/jinja-assets-compressor

tests/contrib/test_flask.py::test_flask_extension_jinja_env_compressor_output_dir tests/contrib/test_flask.py::test_flask_extension_jinja_env_static_prefix
tests/contrib/test_flask.py::test_flask_extension_init_self_app tests/contrib/test_flask.py::test_flask_extension_jinja_env_add_extension tests/contrib/test_flask.py::test_flask_extension_jinja_env_source_dirs
jac/base.py jac/contrib/flask.py
jac/base.py jac/contrib/flask.py