diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7bc250338be35299f96a84f6c58938e1d9023c66..30db01e1ebf5a318fd7f9a5f861ab6a47466742d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -49,16 +49,15 @@ build-native:       # This job runs in the build stage, which runs first.
     - export CCACHE_COMPILERCHECK=content
     - export APT_CACHE_DIR=`pwd`/apt-cache
     - mkdir --parents --verbose $APT_CACHE_DIR/partial/
-    - echo dir::cache::archives="$APT_CACHE_DIR" | tee --append /etc/apt/apt.conf.d/99cache
     - apt-get update
-    - apt-get install --no-install-recommends --yes ccache
+    - apt-get -o dir::cache::archives="$APT_CACHE_DIR" install --no-install-recommends --yes ccache
     - ccache --zero-stats || true
     - ccache --show-stats || true
   after_script:
     - export CCACHE_DIR="$PWD/ccache"
     - ccache --show-stats
   script:
-    - apt-get install --no-install-recommends --yes build-essential libsdl2-mixer-dev libpng-dev libcurl4-openssl-dev libgme-dev git libopenmpt-dev gettext
+    - apt-get -o dir::cache::archives="$APT_CACHE_DIR" install --no-install-recommends --yes build-essential libsdl2-mixer-dev libpng-dev libcurl4-openssl-dev libgme-dev git libopenmpt-dev gettext
     - make --directory=src