Gestion du cache en tant qu’administrateur

For a layer with server cache activated, Lizmap will keep the cache when the user pan and zoom on the map. To have better performance, Lizmap Web Client can also automatically generate the tile cache on the server. In some cases, it is desirable to remove the server cache, for example, when the style has changed and the tiles need to be updated. For this, two solutions are possible:

Suppression de tout le cache par répertoire Lizmap

In the administration interface, The Lizmap configuration menu lists configured Lizmap repository. For each repository, the administrator can delete the cache for all layers of all the projects repository by clicking the button Empty cache.

Supprimer le cache couche par couche pour chaque projet Lizmap

When the administrator is connected and consults a Lizmap map, a little red cross is displayed to the right of the name of each layer that is configured to be server cached. Clicking on the cross allows, after confirmation, to delete the server cache only for this layer in the QGIS project.

Seul un administrateur connecté peut voir ces croix rouges et a le droit de vider le cache.

Générer le cache de tuiles

Vous pouvez prégénérer les tuiles pour n’importe quelles couches d’un projet QGIS configurer pour être mis en cache côté serveur. Pour pouvoir le faire, vous devez avoir un accès complet au serveur sur lequel Lizmap est installé, et utiliser un terminal pour vous y connecter. Vous devez aussi connaître les identifiants des répertoires Lizmap, et le nom d’identification du projet ( le nom du fichier du projet QGIS sans l’extension ).

In this example, we will show commands to manage the tiles cache for the demo project Montpellier, shipped with Lizmap Web Client. We also assume that your Lizmap application is installed in the folder /var/www/lizmap-web-client/.

# Go to the application folder
cd /var/www/lizmap-web-client/

Il est important de savoir que Lizmap publie les couches mises en cache en WMTS (Web Map Tiled Service). Les concepts suivants sont utilisés comme options du générateur de cache de tuile de Lizmap :

  • TileMatrixSet - In Lizmap, this represents the projection code, for example EPSG:3857 (Pseudo mercator).

  • TileMatrixMin - This is the minimum zoom level. This is not a map scale, but a ID of the zoom level. In Lizmap plugin, the project publisher can configure scales for the published project. For example the list : 100000, 50000, 25000, 10000. The zoom level ID depends on some CRS and how you configured your Lizmap project. You can have a idea of the scale ID by typing lizMap.map.getZoom() in your webbrowser Javascript console when zooming on your map.

  • TileMatrixMax - Représente le niveau de zoom maximum

Tout d’abord, vous devez obtenir les possibilités de cache d’un projet, et quelques détails sur une couche spécifique.

# Command help
# php lizmap/scripts/script.php lizmap~wmts:capabilities [-v] repository project [layer] [TileMatrixSet]

# Get the capabilities for a given project published with Lizmap
# and generate the cache about these capabilities.
php lizmap/scripts/script.php lizmap~wmts:capabilities montpellier montpellier

# Get precisions about a specific layer
php lizmap/scripts/script.php lizmap~wmts:capabilities -v montpellier montpellier bus EPSG:3857
# which will return
For "bus" and "EPSG:4326" from TileMatrix 13 to 15
For "bus" and "EPSG:900913" from TileMatrix 14 to 16
For "bus" and "EPSG:3857" from TileMatrix 14 to 16

In this example, you see that the bus layer has 3 different TileMatrixSet, corresponding to the 3 different spatial coordinate systems available for this project in Lizmap(configured in the Project properties, tab QGIS Server).

Il est nécessaire de générer le cache du capabilities avant de générer le cache pour une couche. Le cache du capabilities est utilisé dans la commande suivante. La prochaine commande ne fonctionne pas si le cache du capabilities n’est pas présent.

Une fois que vous avez une bonne connaissance d’une couche, vous pouvez générer le cache pour celle-ci:

# Command help
# php lizmap/scripts/script.php lizmap~wmts:seeding [-v] [-f] repository project layer TileMatrixSet TileMatrixMin TileMatrixMax

# Example
php lizmap/scripts/script.php lizmap~wmts:seeding -v -f montpellier montpellier bus EPSG:3857 12 14
# Which will return:
81 tiles to generate for "bus" "EPSG:3857" "14"
81 tiles to generate for "bus" "EPSG:3857" between "12" and "14"
Start generation
================
Progression: 6%, 5 tiles generated on 81 tiles
Progression: 12%, 10 tiles generated on 81 tiles
Progression: 18%, 15 tiles generated on 81 tiles
Progression: 24%, 20 tiles generated on 81 tiles
Progression: 30%, 25 tiles generated on 81 tiles
Progression: 37%, 30 tiles generated on 81 tiles
Progression: 43%, 35 tiles generated on 81 tiles
Progression: 49%, 40 tiles generated on 81 tiles
Progression: 55%, 45 tiles generated on 81 tiles
Progression: 61%, 50 tiles generated on 81 tiles
Progression: 67%, 55 tiles generated on 81 tiles
Progression: 74%, 60 tiles generated on 81 tiles
Progression: 80%, 65 tiles generated on 81 tiles
Progression: 86%, 70 tiles generated on 81 tiles
Progression: 92%, 75 tiles generated on 81 tiles
Progression: 98%, 80 tiles generated on 81 tiles
================
End generation

Après la génération du cache, mettez à jour les droits dessus :

lizmap/install/set_rights.sh www-data www-data