---
title: Setting Content Type based on file extension
summary: null
url: >-
  https://www.fastly.com/documentation/guides/full-site-delivery/headers/setting-content-type-based-on-file-extension
---

In some situations you may want to override the content type that a backend returns. To do that you will need to create a new header object and an associated condition.

1.   Log in to the [Fastly control panel](https://manage.fastly.com).

2.   From the [**Home**](https://manage.fastly.com/home) page, select the appropriate service. You can use the search box to search by ID, name, or domain.

3.   Click **Edit configuration** and then select the option to clone the active version.

4.   Click **Content**.

5. Click **Create header**.

   ![the Create a header page](/img/new-header-add-new-content-type.png)

6. Fill out the **Create a header** fields as follows:
   - In the **Name** field, enter an appropriate name (e.g.,`Add Content Type`).
   - From the **Type** menu, select **Cache**, and from the **Action** menu, select **Set**.
   - In the **Destination** field, enter `http.Content-Type`.
   - In the **Source** field, enter the content type you want to match, such as `"application/javascript; charset=utf-8"`.
   - From the **Ignore if set** menu, select **No**.
   - In the **Priority** field, enter `10`.

7. Click **Create**.

Once you have created the header object, [apply a condition](https://www.fastly.com/documentation/guides/full-site-delivery/conditions/about-conditions). Otherwise, that particular object is applied to all requests.

1. Click the **Attach condition** button.
2. Fill out the **Create condition** fields as follows:
   - Select the **Type** of condition you want to attach. You can select **Request**, **Cache**, or **Response**.
   - In the **Name** field, enter a descriptive name, such as `Files ending with .js`.
   - In the **Apply if** field, enter the condition that matches your request. For example, if you create a cache condition , you can set `req.url.ext == "js"` (to match the request for files ending in .js).
3. Click \*_Save_. The new condition is created.
4.   From the **Activate** menu, select **Activate on Production** to deploy your configuration changes.

> **HINT:** You may also be interested in our guide to [Removing headers from backend response](https://www.fastly.com/documentation/guides/full-site-delivery/headers/removing-headers-from-backend-response).
