> ## Documentation Index
> Fetch the complete documentation index at: https://docs.safesquid.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Caching and Prefetching

> Configure SafeSquid content caching and prefetching to cut bandwidth and latency, and verify objects are actually being served from the local store.

# Serve Repeated Requests Locally

Every request that reaches the origin costs bandwidth and latency the user feels. Caching stores local copies of requested content and serves later requests from disk; prefetching goes further and retrieves resources referenced in an HTML page before the user asks for them.

They are complementary, and they are configured separately. Caching is the store; prefetching is what fills it ahead of demand.

## Choose which to enable

|                | Content caching                                  | Prefetching                                             |
| -------------- | ------------------------------------------------ | ------------------------------------------------------- |
| What it stores | Pages and files that were requested              | Resources referenced in HTML, before they are requested |
| Best for       | Repeated access to the same content across users | Pages with many embedded assets                         |
| Main cost      | Disk on the write path                           | Origin requests for resources nobody opens              |
| Depends on     | A store policy and a matching access profile     | Caching being configured first                          |

Enable caching first and confirm objects land in the store. Prefetching without a working cache generates origin traffic and discards it.

<Warning>
  Cache and prefetch policy interacts with inspection and privacy scope. Do not cache content from destinations excluded from inspection, or from categories where a shared local copy would expose one user's content to another. Confirm the scope with the policy owner before enabling either.
</Warning>

## Configure content caching

### Create the access policy

1. Access the [SafeSquid User Interface](/safesquid_swg/interface/configuration_portal) and click **Configure**.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image1.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=d367a529c9454fdb924e3ea6e00c2757" alt="Configure page" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image1.webp" />

2. Navigate to **Access Policies** under Restriction Policies.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image2.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=0b847ee8d80632f38093c4930ce046b6" alt="Access Policies section" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image2.webp" />

3. Click **Add New** to create a new policy.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image3.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=de6a24344f902175477f44b02f318eb6" alt="Add new policy" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image3.webp" />

4. Enter a descriptive comment for reference.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image4.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=76e6eec2f075a3662377807859a38ff3" alt="Policy comment" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image4.webp" />

5. Select the desired categories from the **Categories** dropdown.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image5.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=800229201ee6c03408d1071736ffba26" alt="Select categories" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image5.webp" />

6. Set **Action** to **Allow**.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image6.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=3cf512b23de10b3e58015c781b1e02d2" alt="Set action" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image6.webp" />

7. Assign a unique name in **Added Profiles**.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image7.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=844cf2675dd333288a758fc68bcf5e81" alt="Added Profiles" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image7.webp" />

8. Click **Save Policy**.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image8.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=8217fefc044ce513956a38d0e02ef139" alt="Save policy" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image8.webp" />

### Configure the caching store

9. Navigate to **Caching** under Application Setup.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image9.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=96d008aa6a01091dca47cb38698ea2c3" alt="Caching section" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image9.webp" />

10. Click the **Store** tab.

    <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image10.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=189851220ff72e4e9f1a12be6a7e7e7f" alt="Store tab" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image10.webp" />

11. Click **Clone** to duplicate an existing policy.

    <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image11.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=3aab12407509d59be178007ea7138e39" alt="Clone policy" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image11.webp" />

    <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image12.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=697c1bac4fa954635743297ef5e70fef" alt="Duplicated policy" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image12.webp" />

12. Click **Edit Policy** on the cloned entry.

    <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image13.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=515e86632fdebf1f8ba2b56c00962737" alt="Edit policy" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image13.webp" />

13. Set **Enabled** to **True**.

    <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image14.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=f5beeb0a177f882eecf75ee396c3f82e" alt="Enable policy" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image14.webp" />

14. Add an appropriate comment for future reference.

    <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image15.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=e720511d52364a590383025a3350a521" alt="Policy comment" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image15.webp" />

15. Select the profile created earlier from the **Profiles** dropdown.

    <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image16.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=b71cf524b69c4c5513bb7cdc926994de" alt="Select profile" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image16.webp" />

16. Click **Save Policy**.

    <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image17.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=bb326759ed02b5c931b79a649d51829b" alt="Save caching policy" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image17.webp" />

17. Click **Save** to apply the configuration globally.

    <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image18.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=274e978dd1c79f833bad5e1131b58320" alt="Global save" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image18.webp" />

## Configure prefetching

Prefetching fetches and caches files referenced in HTML before the user requests them. It applies to a wider set of resources than caching alone.

1. Access the [SafeSquid User Interface](/safesquid_swg/interface/configuration_portal) and click **Configure**.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/MoDjed1u2_at-9B3/images/How_To/Prefetch_embedded_images/image1.webp?fit=max&auto=format&n=MoDjed1u2_at-9B3&q=85&s=104aab91f5697df587db0fe475afcb25" alt="Configure page" width="1280" height="720" data-path="images/How_To/Prefetch_embedded_images/image1.webp" />

2. Navigate to **Prefetching** under Application Setup.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/MoDjed1u2_at-9B3/images/How_To/Prefetch_embedded_images/image2.webp?fit=max&auto=format&n=MoDjed1u2_at-9B3&q=85&s=03373354657cb557c47cd65a39f85830" alt="Prefetching section" width="1280" height="720" data-path="images/How_To/Prefetch_embedded_images/image2.webp" />

3. Ensure the **Global** section has **Enabled** set to **True**.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/MoDjed1u2_at-9B3/images/How_To/Prefetch_embedded_images/image3.webp?fit=max&auto=format&n=MoDjed1u2_at-9B3&q=85&s=b3189774f00d6da3ce1a8cec3f6ab38a" alt="Global enabled" width="1280" height="720" data-path="images/How_To/Prefetch_embedded_images/image3.webp" />

4. Click the **Prefetch** tab.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/MoDjed1u2_at-9B3/images/How_To/Prefetch_embedded_images/image4.webp?fit=max&auto=format&n=MoDjed1u2_at-9B3&q=85&s=aa026a3a982df3c1fadb317a20a028bd" alt="Prefetch tab" width="1280" height="720" data-path="images/How_To/Prefetch_embedded_images/image4.webp" />

5. Click **Add New** to create a new policy.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/MoDjed1u2_at-9B3/images/How_To/Prefetch_embedded_images/image5.webp?fit=max&auto=format&n=MoDjed1u2_at-9B3&q=85&s=63bf7f0a1f0a522852377b23e7d25e3c" alt="Add new policy" width="1280" height="720" data-path="images/How_To/Prefetch_embedded_images/image5.webp" />

6. Enter an appropriate comment for future reference.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/MoDjed1u2_at-9B3/images/How_To/Prefetch_embedded_images/image6.webp?fit=max&auto=format&n=MoDjed1u2_at-9B3&q=85&s=d257c7d2e84c03aa54bb8d4684dfc434" alt="Policy comment" width="1280" height="720" data-path="images/How_To/Prefetch_embedded_images/image6.webp" />

7. Specify the HTML tag to analyze for prefetchable URLs.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/MoDjed1u2_at-9B3/images/How_To/Prefetch_embedded_images/image7.webp?fit=max&auto=format&n=MoDjed1u2_at-9B3&q=85&s=a3733dcd894206283289aaad5f03cff8" alt="HTML tag specification" width="1280" height="720" data-path="images/How_To/Prefetch_embedded_images/image7.webp" />

8. Specify the attribute of the HTML tag holding the URL to prefetch.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/MoDjed1u2_at-9B3/images/How_To/Prefetch_embedded_images/image8.webp?fit=max&auto=format&n=MoDjed1u2_at-9B3&q=85&s=b7d500d3b0108d617fb58e72c9c38978" alt="Tag attribute" width="1280" height="720" data-path="images/How_To/Prefetch_embedded_images/image8.webp" />

9. Specify the regular expression to evaluate discovered URLs in the tag attribute.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/MoDjed1u2_at-9B3/images/How_To/Prefetch_embedded_images/image9.webp?fit=max&auto=format&n=MoDjed1u2_at-9B3&q=85&s=62d15988d2f082303b10f5c1d8203257" alt="URL regex" width="1280" height="720" data-path="images/How_To/Prefetch_embedded_images/image9.webp" />

10. Click **Save Policy**.

    <img src="https://mintcdn.com/safe-squid-labs-12a0916f/MoDjed1u2_at-9B3/images/How_To/Prefetch_embedded_images/image10.webp?fit=max&auto=format&n=MoDjed1u2_at-9B3&q=85&s=2e4e70273b111abd94f1c3a189b089b3" alt="Save policy" width="1280" height="720" data-path="images/How_To/Prefetch_embedded_images/image10.webp" />

11. Click **Save Config** to apply the configuration.

    <img src="https://mintcdn.com/safe-squid-labs-12a0916f/MoDjed1u2_at-9B3/images/How_To/Prefetch_embedded_images/image11.webp?fit=max&auto=format&n=MoDjed1u2_at-9B3&q=85&s=f7751f4d05520b517b7ff31fb561a7c3" alt="Save config" width="1280" height="720" data-path="images/How_To/Prefetch_embedded_images/image11.webp" />

    <img src="https://mintcdn.com/safe-squid-labs-12a0916f/MoDjed1u2_at-9B3/images/How_To/Prefetch_embedded_images/image12.webp?fit=max&auto=format&n=MoDjed1u2_at-9B3&q=85&s=644f84c1490008c14a246a65220c0695" alt="Configuration saved" width="1280" height="720" data-path="images/How_To/Prefetch_embedded_images/image12.webp" />

Keep the regular expression narrow. A broad pattern prefetches every URL the tag attribute can hold, which turns a latency optimisation into an origin-traffic multiplier.

## Verify objects are cached

1. Navigate to **Manage Cached Objects** in the Caching section.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image19.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=2e7fe6afe2e614d7584332ba28aa000a" alt="Manage Cached Objects" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image19.webp" />

2. Verify cached websites appear under disk cache.

   <img src="https://mintcdn.com/safe-squid-labs-12a0916f/D_QM4_e4oHdWyIb0/images/How_To/Caching_Specific_websites/image20.webp?fit=max&auto=format&n=D_QM4_e4oHdWyIb0&q=85&s=09308f264a03dbc5e1e925e75681b8d9" alt="Disk cache contents" width="1280" height="720" data-path="images/How_To/Caching_Specific_websites/image20.webp" />

Expected result: content from the categories in the access profile appears in the disk cache after a client requests it.

An empty store after browsing means the access profile is not matching, or the store policy is not enabled — check the profile name in both places before adjusting cache size.

## Capture caching evidence

Store these artifacts with the change record:

* The access profile name and the categories it matches.
* Confirmation that the store policy references that same profile.
* A **Manage Cached Objects** listing showing entries after a test browse.
* The prefetch tag, attribute, and regular expression used.
* Confirmation from the policy owner that cached categories are appropriate to share.

## Troubleshoot caching and prefetching

| Symptom                                      | Likely cause                                                    | Fix                                                                                  |
| -------------------------------------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| Disk cache stays empty                       | Store policy is not enabled, or references the wrong profile    | Confirm **Enabled** is `True` and the profile name matches the access policy exactly |
| Cache fills but hit rate stays low           | Categories cached do not match what users request               | Re-scope the access profile to the categories actually in demand                     |
| Origin traffic rises after enabling prefetch | Regular expression is too broad                                 | Narrow the pattern; prefetching every matched URL costs more than it saves           |
| Users see another user's content             | Cached content from a personalised or authenticated destination | Exclude those categories from the store policy immediately                           |
| Disk I/O wait rises sharply                  | Cache on a SATA-attached volume                                 | Move the cache path to NVMe; see [Sizing](/deployment/sizing)                        |

## Next steps

* [Manage Bandwidth](/use_cases/performance_acceleration/manage_bandwidth) - shape traffic once caching is in place.
* [Performance Plot](/use_cases/performance_acceleration/performance_plot) - measure the effect on latency.
* [Sizing](/deployment/sizing) - confirm the cache volume is on the right storage.


## Related topics

- [Performance Accelerators](/use_cases/performance_acceleration/performance_accelerators.md)
- [Prefetch](/admin_guide/performance/prefetching.md)
- [Security Logs](/use_cases/audit_and_forensics/security_logs.md)
- [Architecture and request pipeline](/admin_guide/start_here/architecture.md)
- [BIND Local DNS Resolver](/safesquid_swg/interface/bind.md)
