# Cloudflare not caching much

**URL:** https://forum.infinityfree.com/t/cloudflare-not-caching-much/60163
**Category:** Hosting Support
**Created:** [April 7, 2022, 6:44pm UTC](https://forum.infinityfree.com/t/cloudflare-not-caching-much/60163 "2022-04-07T18:44:27Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![lovebug](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/lovebug/32/57624_2.png) [@lovebug](https://forum.infinityfree.com/u/lovebug)
#### Post date: [April 7, 2022, 6:44pm UTC](https://forum.infinityfree.com/t/cloudflare-not-caching-much/60163/1 "2022-04-07T18:44:27Z")

</div>

[https://lovebyte.eu.org](https://lovebyte.eu.org)

 ![image](https://forum-cdn.infinityfree.net/original/3X/e/e/ee055dbaf9a0060d5428a44048952cdbcf556604.png)

is there any way to improve the caching ?

thanks

---

<div class="post-metadata">

### Author: ![Greenreader9](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/greenreader9/32/22847_2.png) [@Greenreader9](https://forum.infinityfree.com/u/Greenreader9)
#### Post date: [April 7, 2022, 6:46pm UTC](https://forum.infinityfree.com/t/cloudflare-not-caching-much/60163/2 "2022-04-07T18:46:09Z")

</div>

Without knowing how your website is made, no one can help you. Cloudflare can only cache images, HTML, CSS, and JS, not PHP or other technologies that you may be using.

---

<div class="post-metadata">

### Author: ![lovebug](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/lovebug/32/57624_2.png) [@lovebug](https://forum.infinityfree.com/u/lovebug)
#### Post date: [April 7, 2022, 6:48pm UTC](https://forum.infinityfree.com/t/cloudflare-not-caching-much/60163/3 "2022-04-07T18:48:03Z")

</div>

i have an index.php and that loads html pages which contain some images and css

---

<div class="post-metadata">

### Author: ![lovebug](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/lovebug/32/57624_2.png) [@lovebug](https://forum.infinityfree.com/u/lovebug)
#### Post date: [April 7, 2022, 6:49pm UTC](https://forum.infinityfree.com/t/cloudflare-not-caching-much/60163/4 "2022-04-07T18:49:35Z")

</div>

```auto
<?php
	// check for valid pages and select page and title
	switch($_GET['page'])
	{
		case 'servers':
// $page = 'servers.php';
			$page = 'servers.html';
			$title = 'Servers';
			break;

		case 'art':
			$page = 'art.html';
			$title = 'Gallery';
			break;
			
		case 'projects':
			$page = 'projects.html';
			$title = 'Projects';
			break;
			
		case 'project-z80-disassembler':
			$page = 'project-z80-disassembler.html';
			$title = 'Project Z80 Disassembler';
			break;
			
		case 'project-ladybug-bbc':
			$page = 'project-ladybug-bbc.html';
			$title = 'Project Lady Bug BBC';
			break;
			
		case 'project-ladybug':
			$page = 'project-ladybug.html';
			$title = 'Project Lady Bug';
			break;
			
		case 'websites':
			$page = 'websites.html';
			$title = 'Websites';
			break;
			
		case 'error400':
			$page = 'error400.html';
			$title = '400';
			break;
			
		case 'error401':
			$page = 'error401.html';
			$title = '401';
			break;
			
		case 'error403':
			$page = 'error403.html';
			$title = '403';
			break;
			
		case 'error404':
			$page = 'error404.html';
			$title = '404';
			break;
			
		case 'error500':
			$page = 'error500.html';
			$title = '500';
			break;
			
		case 'error503':
			$page = 'error503.html';
			$title = '503';
			break;
			
		case 'blank-template':
			$page = 'blank-template.html';
			$title = 'Blank Template';
			break;
			
		default:
			$page = 'news.html';
			$title = 'News';
	}

?>
	
<!DOCTYPE html>
<!--
 _______         
| | ____ ____ | __|_ ____ 
| | __| . | | | -_|__ -| | | . |
| _____|___ |\_/| ___|_____ |___|_ |
                            |___|
-->

<html lang='en'>

	<head>

		<meta charset='UTF-8'>
		<title>LoveBug - <?php echo $title; ?></title>
		<link rel='icon' type='image/png' href='/images/favicon-mushroom-48.png' />
		<link rel='stylesheet' href='/lovebug.css?<?php echo filemtime($_SERVER["DOCUMENT_ROOT"] . "/lovebug.css"); ?>' />

	</head>

	<body id='main-body'>
	
		<!-- include navigation menu -->
		<?php include $_SERVER['DOCUMENT_ROOT'] . '/navigation.html'; ?>
		<!-- end navigation menu -->

		<!-- spacer before content -->
		<div class='spacer'></div>
		<!-- end spacer -->

		<!-- include required page content -->
		<?php include $_SERVER['DOCUMENT_ROOT'] . '/' . $page; ?>
		<!-- end page content -->

	</body>

</html>

```

---

<div class="post-metadata">

### Author: ![Greenreader9](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/greenreader9/32/22847_2.png) [@Greenreader9](https://forum.infinityfree.com/u/Greenreader9)
#### Post date: [April 7, 2022, 7:00pm UTC](https://forum.infinityfree.com/t/cloudflare-not-caching-much/60163/5 "2022-04-07T19:00:43Z")

</div>

So the PHP doc is not cached, but the HTML files probably are. So each reload is going to cause at least one un-cached hit (from the PHP file).

---

<div class="post-metadata">

### Author: ![lovebug](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/lovebug/32/57624_2.png) [@lovebug](https://forum.infinityfree.com/u/lovebug)
#### Post date: [April 7, 2022, 7:04pm UTC](https://forum.infinityfree.com/t/cloudflare-not-caching-much/60163/6 "2022-04-07T19:04:55Z")

</div>

oh thanks, maybes its ok then

---

<div class="post-metadata">

### Author: ![Oxy](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/oxy/32/37989_2.png) [@Oxy](https://forum.infinityfree.com/u/Oxy)
#### Post date: [April 7, 2022, 7:52pm UTC](https://forum.infinityfree.com/t/cloudflare-not-caching-much/60163/7 "2022-04-07T19:52:42Z")

</div>

HTML is not included in the cache  
it must be enabled

- [Default Cache Behavior · Cloudflare Cache (CDN) docs](https://developers.cloudflare.com/cache/about/default-cache-behavior/)

- [Create Edge Cache TTL page rules · Cloudflare Cache (CDN) docs](https://developers.cloudflare.com/cache/how-to/create-page-rules/#cache-everything)

- [here are two pictures to see what it should look like if you want cache HTML and much more](https://forum.infinityfree.com/t/tips-for-quality-website-design/10891/16)

---

<div class="post-metadata">

### Author: ![lovebug](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/lovebug/32/57624_2.png) [@lovebug](https://forum.infinityfree.com/u/lovebug)
#### Post date: [April 7, 2022, 10:57pm UTC](https://forum.infinityfree.com/t/cloudflare-not-caching-much/60163/8 "2022-04-07T22:57:35Z")

</div>

@Oxy Ive done the cache all thing, thanks for the tip

---

<div class="post-metadata">

### Author: ![Oxy](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/oxy/32/37989_2.png) [@Oxy](https://forum.infinityfree.com/u/Oxy)
#### Post date: [April 8, 2022, 2:52pm UTC](https://forum.infinityfree.com/t/cloudflare-not-caching-much/60163/9 "2022-04-08T14:52:21Z")

</div>

You’re welcome

Now you just need to remember when you make some changes (like uploading newer versions)  
to make a **purge all** on the CF cache section (or a selective purge - which sometimes doesn’t really work for me)  
so CF starts serving fresh versions of pages or files, not cached ones.

---

<div class="post-metadata">

### Author: ![lovebug](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/lovebug/32/57624_2.png) [@lovebug](https://forum.infinityfree.com/u/lovebug)
#### Post date: [April 8, 2022, 2:53pm UTC](https://forum.infinityfree.com/t/cloudflare-not-caching-much/60163/10 "2022-04-08T14:53:15Z")

</div>

yeah i’ll do that, thanks 😃

---

<div class="post-metadata">

### Author: ![Oxy](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/oxy/32/37989_2.png) [@Oxy](https://forum.infinityfree.com/u/Oxy)
#### Post date: [April 8, 2022, 3:08pm UTC](https://forum.infinityfree.com/t/cloudflare-not-caching-much/60163/11 "2022-04-08T15:08:39Z")

</div>

Just to draw your attention to one thing:

**Page Rules** (if you have more than one) they depend on the priority  
so the ones you put higher (number 1 for example) will have higher priority  
compared to the ones below, so if you have some problems and it doesn’t behave as you determined then you need to take care of the priority.

eg I have **cache everything** (for all)  
but I also have a few PHP (dynamic) pages that I excluded from the cache policy because otherwise, I would serve the same page to each visitor instead of having the ability to post something and get a session and cookies, etc.

So I need to isolate such pages (URL / PATH) from the cache evr. rule and serve them as a **standard cache**.

 ![image](https://forum-cdn.infinityfree.net/original/3X/4/a/4af8b0f9825731a19821a0273dc65ba44cff721b.png)

---

<div class="post-metadata">

### Author: ![lovebug](https://forum.infinityfree.com/user_avatar/forum.infinityfree.com/lovebug/32/57624_2.png) [@lovebug](https://forum.infinityfree.com/u/lovebug)
#### Post date: [April 8, 2022, 7:40pm UTC](https://forum.infinityfree.com/t/cloudflare-not-caching-much/60163/12 "2022-04-08T19:40:06Z")

</div>

thanks for the tip

currently my game servers are offline but when (if) i can bring them back i’ll have to add a rule to not cache the players online page

---

<div class="post-metadata">

### Author: ![system](https://infinityfree-forum-uploads.s3.dualstack.eu-central-1.amazonaws.com/original/3X/b/0/b024fd3fa88bae093c9576e55c2c94e33f890206.svg) [@system](https://forum.infinityfree.com/u/system)
#### Post date: [April 15, 2022, 7:40pm UTC](https://forum.infinityfree.com/t/cloudflare-not-caching-much/60163/13 "2022-04-15T19:40:19Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
