# How Discourse handle high HTTP request?

**URL:** https://meta.discourse.org/t/how-discourse-handle-high-http-request/111261
**Category:** Development
**Created:** [March 11, 2019, 10:20am UTC](https://meta.discourse.org/t/how-discourse-handle-high-http-request/111261 "2019-03-11T10:20:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![saiqulhaq](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saiqulhaq/32/119871_2.png) [@saiqulhaq](https://meta.discourse.org/u/saiqulhaq)
#### Post date: [March 11, 2019, 10:20am UTC](https://meta.discourse.org/t/how-discourse-handle-high-http-request/111261/1 "2019-03-11T10:20:35Z")

</div>

I just take a look at the source code, there is no Rails `#stale?` method on controller to return 304  
or cache the entire page based on record cache key

Sorry to bother you, I’m just curious about this

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 12, 2019, 2:04am UTC](https://meta.discourse.org/t/how-discourse-handle-high-http-request/111261/2 "2019-03-12T02:04:35Z")

</div>

People are not hitting reload like crazy on Discourse … we rarely need this kind of protection. And will just use rate limiting for that.

Instead we rely on anonymous cache for the bulk of our high load handling. It has 2 modes

- For high hits from anon we cache home page and topic pages for up to 1 minute
- For high hits from logged in, we revert to anon if a topic page is under extreme load

You can read through for all the gory implementation.

> <https://github.com/discourse/discourse/blob/be5e889b1b55de148b32ae864390a585e027b1ec/lib/middleware/anonymous_cache.rb>

We also have tons of internal caching of bits and pieces to avoid high cost queries.

---

<div class="post-metadata">

### Author: ![saiqulhaq](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/saiqulhaq/32/119871_2.png) [@saiqulhaq](https://meta.discourse.org/u/saiqulhaq)
#### Post date: [March 12, 2019, 5:03am UTC](https://meta.discourse.org/t/how-discourse-handle-high-http-request/111261/3 "2019-03-12T05:03:20Z")

</div>

ok thanks for the enlightenment

I will read the source code more deeper
