# Django キャッシュ (Django) > キャッシュバックエンド、ビュー単位のキャッシュ、テンプレートフラグメントキャッシュ、低レベルキャッシュ API、キャッシュの無効化 - 20 面接問題 - Mid-Level - [面接問題: Django](https://sharpskill.dev/ja/technologies/django/interview-questions.md) ## 1. 設定が指定されていない場合、Django のデフォルトのキャッシュバックエンドは何ですか? **回答** Django はデフォルトで 'LocMemCache' バックエンド(ローカルメモリキャッシュ)を使用し、データを Python プロセスのメモリに保存します。このバックエンドはシンプルで高速ですが、サーバーの再起動間でデータが保持されず、異なるプロセス間でデータを共有しません。開発には適していますが、マルチプロセスの本番環境には推奨されません。 ## 2. ビューの完全なレスポンスを 15 分間キャッシュするにはどのデコレータを使用しますか? **回答** django.views.decorators.cache の cache_page デコレータは、ビューの完全な HTTP レスポンスをキャッシュします。パラメータは秒単位の時間です(15 分 = 900 秒)。キャッシュキーは URL とクエリパラメータから自動的に生成されます。このデコレータはキャッシュ用の適切な HTTP ヘッダーも処理します。 ## 3. テンプレートフラグメントを 5 分間キャッシュするためのテンプレートタグの正しい構文は何ですか? **回答** {% cache %} タグはテンプレートフラグメントをキャッシュします。構文は {% cache timeout cache_name %}...{% endcache %} です。最初の引数は秒単位の時間(5 分なら 300)、2 番目はこのフラグメントを識別する一意の名前です。キャッシュを変化させるために追加の引数を加えることもできます(例: user.id)。 ## さらに17問利用可能 - キーが存在しない場合にデフォルト値を使ってキャッシュから値を取得するにはどうしますか? - 複数インスタンスを持つ本番環境の Django アプリケーションには、どのキャッシュバックエンドが推奨されますか? 無料で登録: https://sharpskill.dev/ja/login ## その他のDjango面接トピック - [Pythonの基礎](https://sharpskill.dev/ja/technologies/django/interview-questions/python-basics.md): 25問, Junior - [Python オブジェクト指向](https://sharpskill.dev/ja/technologies/django/interview-questions/python-oop.md): 20問, Junior - [Django の基礎](https://sharpskill.dev/ja/technologies/django/interview-questions/django-fundamentals.md): 20問, Junior - [Django Models - 基礎](https://sharpskill.dev/ja/technologies/django/interview-questions/django-models-basics.md): 22問, Junior - [Django ビュー](https://sharpskill.dev/ja/technologies/django/interview-questions/django-views.md): 20問, Junior - [Django テンプレート](https://sharpskill.dev/ja/technologies/django/interview-questions/django-templates.md): 18問, Junior - [Django フォーム](https://sharpskill.dev/ja/technologies/django/interview-questions/django-forms.md): 22問, Mid-Level - [高度なQuerySet](https://sharpskill.dev/ja/technologies/django/interview-questions/django-querysets.md): 25問, Mid-Level - [Django 認証](https://sharpskill.dev/ja/technologies/django/interview-questions/django-authentication.md): 22問, Mid-Level - [Django ミドルウェア](https://sharpskill.dev/ja/technologies/django/interview-questions/django-middleware.md): 18問, Mid-Level - [Django Admin](https://sharpskill.dev/ja/technologies/django/interview-questions/django-admin.md): 20問, Mid-Level - [Django REST Framework](https://sharpskill.dev/ja/technologies/django/interview-questions/django-rest-framework.md): 30問, Mid-Level - [Django シグナル](https://sharpskill.dev/ja/technologies/django/interview-questions/django-signals.md): 18問, Mid-Level - [ファイルアップロード](https://sharpskill.dev/ja/technologies/django/interview-questions/django-file-upload.md): 20問, Mid-Level - [Django セッション](https://sharpskill.dev/ja/technologies/django/interview-questions/django-sessions.md): 18問, Mid-Level - [Django のメール](https://sharpskill.dev/ja/technologies/django/interview-questions/django-email.md): 18問, Mid-Level - [Django のテスト](https://sharpskill.dev/ja/technologies/django/interview-questions/django-testing.md): 22問, Mid-Level - [Django のセキュリティ](https://sharpskill.dev/ja/technologies/django/interview-questions/django-security.md): 22問, Mid-Level - [Django のデプロイ](https://sharpskill.dev/ja/technologies/django/interview-questions/django-deployment.md): 24問, Mid-Level - [Django ORM 上級](https://sharpskill.dev/ja/technologies/django/interview-questions/django-orm-advanced.md): 28問, Senior - [Django のパフォーマンス](https://sharpskill.dev/ja/technologies/django/interview-questions/django-performance.md): 24問, Senior - [Django & Celery](https://sharpskill.dev/ja/technologies/django/interview-questions/django-celery.md): 22問, Senior - [Django Channels](https://sharpskill.dev/ja/technologies/django/interview-questions/django-channels.md): 24問, Senior - [Django & GraphQL](https://sharpskill.dev/ja/technologies/django/interview-questions/django-graphql.md): 24問, Senior - [Django & Docker](https://sharpskill.dev/ja/technologies/django/interview-questions/django-docker.md): 20問, Senior - [マイクロサービスエコシステムにおけるDjango](https://sharpskill.dev/ja/technologies/django/interview-questions/django-microservices.md): 24問, Senior - [カスタムDjangoコマンド](https://sharpskill.dev/ja/technologies/django/interview-questions/django-custom-commands.md): 18問, Senior - [Django の国際化](https://sharpskill.dev/ja/technologies/django/interview-questions/django-internationalization.md): 20問, Senior - [Django デザインパターン](https://sharpskill.dev/ja/technologies/django/interview-questions/django-design-patterns.md): 24問, Senior - [Django Async と ASGI](https://sharpskill.dev/ja/technologies/django/interview-questions/django-async-asgi.md): 26問, Senior - [Settings と本番環境の設定](https://sharpskill.dev/ja/technologies/django/interview-questions/django-settings-configuration.md): 22問, Senior - [オブザーバビリティとモニタリング](https://sharpskill.dev/ja/technologies/django/interview-questions/django-observability.md): 24問, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/ja/technologies/django/interview-questions/django-caching