# Django Caching (Django) > Cache backends, per-view cache, template fragment cache, low-level cache API, cache invalidation - 20 interview questions - Mid-Level - [Interview Questions: Django](https://sharpskill.dev/en/technologies/django/interview-questions.md) ## 1. What is the default cache backend in Django if no configuration is specified? **Answer** Django uses the 'LocMemCache' backend (local memory cache) by default which stores data in the Python process memory. This backend is simple and fast but doesn't persist between server restarts and doesn't share data across different processes. It's suitable for development but not recommended for multi-process production environments. ## 2. Which decorator should be used to cache the complete response of a view for 15 minutes? **Answer** The cache_page decorator from django.views.decorators.cache caches the complete HTTP response of a view. The parameter is the time in seconds (15 minutes = 900 seconds). The cache key is automatically generated from the URL and query parameters. This decorator also handles appropriate HTTP headers for caching. ## 3. What is the correct syntax for the template tag to cache a template fragment for 5 minutes? **Answer** The {% cache %} tag caches a template fragment. The syntax is {% cache timeout cache_name %}...{% endcache %}. The first argument is the time in seconds (300 for 5 minutes), the second is a unique name to identify this fragment. Additional arguments can be added to vary the cache (e.g., user.id). ## 17 more questions available - How to retrieve a value from cache with a default value if the key doesn't exist? - Which cache backend is recommended for a Django application in production with multiple instances? Sign up for free: https://sharpskill.dev/en/login ## Other Django interview topics - [Python Basics](https://sharpskill.dev/en/technologies/django/interview-questions/python-basics.md): 25 questions, Junior - [Python OOP](https://sharpskill.dev/en/technologies/django/interview-questions/python-oop.md): 20 questions, Junior - [Django Fundamentals](https://sharpskill.dev/en/technologies/django/interview-questions/django-fundamentals.md): 20 questions, Junior - [Django Models - Basics](https://sharpskill.dev/en/technologies/django/interview-questions/django-models-basics.md): 22 questions, Junior - [Django Views](https://sharpskill.dev/en/technologies/django/interview-questions/django-views.md): 20 questions, Junior - [Django Templates](https://sharpskill.dev/en/technologies/django/interview-questions/django-templates.md): 18 questions, Junior - [Django Forms](https://sharpskill.dev/en/technologies/django/interview-questions/django-forms.md): 22 questions, Mid-Level - [Advanced QuerySets](https://sharpskill.dev/en/technologies/django/interview-questions/django-querysets.md): 25 questions, Mid-Level - [Django Authentication](https://sharpskill.dev/en/technologies/django/interview-questions/django-authentication.md): 22 questions, Mid-Level - [Django Middleware](https://sharpskill.dev/en/technologies/django/interview-questions/django-middleware.md): 18 questions, Mid-Level - [Django Admin](https://sharpskill.dev/en/technologies/django/interview-questions/django-admin.md): 20 questions, Mid-Level - [Django REST Framework](https://sharpskill.dev/en/technologies/django/interview-questions/django-rest-framework.md): 30 questions, Mid-Level - [Django Signals](https://sharpskill.dev/en/technologies/django/interview-questions/django-signals.md): 18 questions, Mid-Level - [File Upload](https://sharpskill.dev/en/technologies/django/interview-questions/django-file-upload.md): 20 questions, Mid-Level - [Django Sessions](https://sharpskill.dev/en/technologies/django/interview-questions/django-sessions.md): 18 questions, Mid-Level - [Django Email](https://sharpskill.dev/en/technologies/django/interview-questions/django-email.md): 18 questions, Mid-Level - [Django Testing](https://sharpskill.dev/en/technologies/django/interview-questions/django-testing.md): 22 questions, Mid-Level - [Django Security](https://sharpskill.dev/en/technologies/django/interview-questions/django-security.md): 22 questions, Mid-Level - [Django Deployment](https://sharpskill.dev/en/technologies/django/interview-questions/django-deployment.md): 24 questions, Mid-Level - [Advanced Django ORM](https://sharpskill.dev/en/technologies/django/interview-questions/django-orm-advanced.md): 28 questions, Senior - [Django Performance](https://sharpskill.dev/en/technologies/django/interview-questions/django-performance.md): 24 questions, Senior - [Django & Celery](https://sharpskill.dev/en/technologies/django/interview-questions/django-celery.md): 22 questions, Senior - [Django Channels](https://sharpskill.dev/en/technologies/django/interview-questions/django-channels.md): 24 questions, Senior - [Django & GraphQL](https://sharpskill.dev/en/technologies/django/interview-questions/django-graphql.md): 24 questions, Senior - [Django & Docker](https://sharpskill.dev/en/technologies/django/interview-questions/django-docker.md): 20 questions, Senior - [Django in Microservices Ecosystem](https://sharpskill.dev/en/technologies/django/interview-questions/django-microservices.md): 24 questions, Senior - [Custom Django Commands](https://sharpskill.dev/en/technologies/django/interview-questions/django-custom-commands.md): 18 questions, Senior - [Django Internationalization](https://sharpskill.dev/en/technologies/django/interview-questions/django-internationalization.md): 20 questions, Senior - [Django Design Patterns](https://sharpskill.dev/en/technologies/django/interview-questions/django-design-patterns.md): 24 questions, Senior - [Django Async & ASGI](https://sharpskill.dev/en/technologies/django/interview-questions/django-async-asgi.md): 26 questions, Senior - [Settings & Production Configuration](https://sharpskill.dev/en/technologies/django/interview-questions/django-settings-configuration.md): 22 questions, Senior - [Observability & Monitoring](https://sharpskill.dev/en/technologies/django/interview-questions/django-observability.md): 24 questions, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/en/technologies/django/interview-questions/django-caching