diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ba234b4ef8ac6c3456a7274562e780e574b62547..a4be8cd7cc7de7dc171d68e81c7bd5a9da1636ab 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -24,6 +24,7 @@ variables:
   ANDROID_HOME: "/usr/local/android-sdk" # should already be defined in the Docker image
   ANDROID_SDK_ROOT: "/usr/local/android-sdk" # should already be defined in the Docker image
   RELEASES_PATH: "$PROD_PATH/cassiopee-releases"
+  CACHE_KEY: $([$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_REF_NAME == "devel"] && echo $CI_COMMIT_REF_NAME || cat jalhyd_branch)
 
 before_script:
   # load private key from GitLab CI variable to deploy on Aubes server
@@ -35,11 +36,25 @@ before_script:
   - mkdir -p ~/.ssh
   - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
 
-cache:
-  paths:
-    - node_modules/
+.protected_branches:
+  cache:
+    key: $CI_COMMIT_REF_NAME
+  only: 
+    - master
+    - devel
+
+.other_branches:
+  cache:
+    key:
+      file jalhyd_branch
+  except:
+    - master
+    - devel
 
 jalhyd:
+  extends:
+    - .protected_branches
+    - .other_branches
   stage: jalhyd
   only:
     - pushes
@@ -61,6 +76,9 @@ jalhyd:
     - npm run build
 
 install:
+  extends:
+    - .protected_branches
+    - .other_branches
   stage: install
   only:
     - pushes
@@ -72,6 +90,9 @@ install:
     - npm ci --force --unsafe-perm
 
 test:
+  extends:
+    - .protected_branches
+    - .other_branches
   stage: test
   only:
     - tags
@@ -81,6 +102,9 @@ test:
     - npm run e2e
 
 build:
+  extends:
+    - .protected_branches
+    - .other_branches
   stage: build
   only:
     - pushes
@@ -95,6 +119,9 @@ build:
     - npm run build -- --base-href=/cassiopee/$CI_COMMIT_REF_NAME/
 
 clean-stale-branches:
+  extends:
+    - .protected_branches
+    - .other_branches
   stage: clean-stale-branches
   only:
     - pushes
@@ -104,6 +131,9 @@ clean-stale-branches:
     - ./scripts/remove-stale-branches.sh $DEV_LOGIN@$DEV_HOST $DEV_PATH
 
 deploy-dev:
+  extends:
+    - .protected_branches
+    - .other_branches
   stage: deploy-dev
   only:
     - pushes
@@ -116,6 +146,9 @@ deploy-dev:
     - ./scripts/deploy-version.sh $CI_COMMIT_REF_NAME $DEV_LOGIN $DEV_HOST $DEV_PATH
 
 deploy-prod:
+  extends:
+    - .protected_branches
+    - .other_branches
   stage: deploy-prod
   only:
     variables:
@@ -126,6 +159,9 @@ deploy-prod:
     - ./scripts/deploy-version.sh stable $PROD_LOGIN $PROD_HOST $PROD_PATH $PROD_PASS
 
 releases-nightly:
+  extends:
+    - .protected_branches
+    - .other_branches
   stage: releases-nightly
   only:
     - schedules
@@ -137,6 +173,9 @@ releases-nightly:
     - ./scripts/release-version.sh nightly $PROD_LOGIN $PROD_HOST $RELEASES_PATH
 
 releases-version:
+  extends:
+    - .protected_branches
+    - .other_branches
   stage: releases-version
   only:
     variables: