When a website loads slowly, the cause is not only in the source code or hosting. The distance from the server to the viewer also matters, especially when visitors are in many different regions. A CDN is one way to ease this problem, and Cloudflare is a service known to many small website owners because its basic plan is easy to start with. This article explains the main concepts and the points that are easy to confuse.
A CDN Keeps Copies Close to Viewers
A CDN (content delivery network) is a system of servers placed in many locations. When someone visits, static files such as images, CSS, JavaScript, and fonts can be served from a server near them instead of always going back to the origin server. As a result, pages load faster and the origin server handles fewer repeated requests.
Keep in mind that a CDN does not replace weak hosting. If the page itself is slow because of database queries or heavy plugins, you still need to optimize at the source. Before switching services, consider refreshing or rebuilding the website to find out where the problem lies.
DNS, Proxy, and Cache
With Cloudflare, you usually point your domain name to their nameservers. When a DNS record is set to proxy mode, HTTP/HTTPS traffic passes through Cloudflare before reaching the origin server, and the origin server's real IP address is not exposed. Thanks to this intermediary position, Cloudflare can also cache content and apply protective layers.
Static files such as images, CSS, and JS are usually cached under the default configuration. According to Cloudflare's documentation, HTML and JSON are not cached by default; to cache entire pages you need to create a separate rule. Cloudflare also respects Cache-Control headers from the origin server, and will not cache when directives such as private or no-store are present.
Basic Bot and DDoS Protection
When traffic passes through Cloudflare's network, distributed denial-of-service (DDoS) attacks can be absorbed and partly filtered before reaching your server. This is why many small websites use Cloudflare as a first layer of protection. There are additional tools such as firewall rules, restricting access from certain countries, or blocking suspicious bots, depending on the plan.
However, this is only network-level protection. A website still needs plugin updates, strong passwords, and regular backups. If you use WordPress, see also what to know when updating to 5.0 to understand testing before updating.
Notes on SSL and Caching Dynamic Pages
Two areas most often cause errors when enabling a CDN:
- SSL/TLS mode. Cloudflare has the modes Off, Flexible, Full, and Full (strict). In Flexible mode, the connection between the visitor and Cloudflare is encrypted but the leg from Cloudflare to the origin server is not. Cloudflare recommends using Full or Full (strict) whenever possible. If your website has a valid certificate, choosing Full (strict) is safer. When handling invoices and customer data, keep the connection encrypted on both legs; you can read more background in the article on e-invoices under Decree 119/2018.
- Dynamic pages and login areas. Carts, account pages, and admin pages should not be cached and shared among everyone. If you enable a rule that caches entire pages, exclude these paths, and test by logging in and then trying to change content.
After making changes, clear the cache when updating large amounts of content and re-check the pages on mobile. When deploying, structured data (schema) and robots.txt also need to remain readable through the CDN.
Khi nào nên dùng CDN, khi nào chưa cần
CDN phát huy tác dụng rõ khi website có nhiều ảnh, khách ở nhiều tỉnh hoặc nước, hoặc thường xuyên có lượng truy cập tăng đột ngột sau chiến dịch quảng cáo. Ngược lại, một website giới thiệu nhỏ, khách chủ yếu ở cùng một thành phố với máy chủ, có thể chưa thấy chênh lệch lớn. Trước tiên hãy đo tốc độ hiện tại để biết CDN có giải quyết đúng nút thắt hay không.
Các bước bật Cloudflare an toàn cho website đang chạy
- Ghi lại toàn bộ bản ghi DNS hiện có (A, CNAME, MX, TXT) trước khi đổi, đặc biệt bản ghi email.
- Kiểm tra Cloudflare đã nhập đủ bản ghi chưa, và bản ghi mail phải để chế độ chỉ DNS, không qua proxy.
- Chọn chế độ SSL phù hợp với chứng chỉ hiện có trên máy chủ gốc.
- Đổi nameserver tại nơi đăng ký tên miền, rồi chờ lan truyền.
- Kiểm tra trang chủ, đăng nhập, giỏ hàng, biểu mẫu liên hệ trên điện thoại và máy tính.
- Sau vài ngày, xem báo cáo lưu lượng và lỗi để điều chỉnh.
Lỗi hay gặp khi bật CDN
- Email ngừng hoạt động: do bản ghi MX hoặc bản ghi dùng cho mail bị đặt qua proxy hoặc nhập thiếu. Đối chiếu lại với bản ghi đã chép ở bước đầu.
- Nội dung cũ vẫn hiện: vì bộ nhớ đệm chưa làm mới. Tài liệu Cloudflare có hướng dẫn xoá bộ nhớ đệm (purge cache) toàn bộ hoặc theo từng địa chỉ; tra ngày 03/12/2026.
- Lỗi chuyển hướng lặp: thường do chế độ SSL và chuyển hướng HTTPS trên máy chủ gốc không khớp nhau.
- Địa chỉ IP khách bị ghi nhận thành IP của CDN: nhật ký truy cập và plugin bảo mật cần được cấu hình để đọc đúng IP thật của khách.
Bảo mật tài khoản CDN
Tài khoản CDN nắm quyền đổi DNS của tên miền. Nếu bị chiếm, kẻ xấu có thể đổi website sang nơi khác. Hãy bật xác thực hai lớp, dùng mật khẩu riêng, hạn chế số người có quyền quản trị và ghi rõ ai giữ tài khoản khi nhân sự thay đổi.
If you need support configuring acceleration for your website, you can contact HVSC's Technology team via the page designing the website.
2026 update: Cloudflare's documentation still states that HTML is not cached by default and recommends using SSL mode Full or Full (strict). The interface and service plans have changed a lot, so see developers.cloudflare.com for up-to-date guidance.
FAQ
Do I Need to Change Hosting to Use Cloudflare?
Not required. Cloudflare sits in front of your existing server. But you should check SSL compatibility and cache configuration.
Why Is the Site Still Slow After Enabling a CDN?
It may be due to processing on the origin server, data queries, or heavy plugins. A CDN mainly helps with static files.
Should I Cache Entire Pages?
Only for pages that rarely change. Cart, account, and admin pages must be excluded.
Reference sources
- Cloudflare Docs — How Cloudflare works: https://developers.cloudflare.com/fundamentals/concepts/how-cloudflare-works/
- Cloudflare Docs — Default cache behavior: https://developers.cloudflare.com/cache/concepts/default-cache-behavior/
- Cloudflare Docs — SSL/TLS encryption modes: https://developers.cloudflare.com/ssl/origin-configuration/ssl-modes/
- Cloudflare — Purge cache: https://developers.cloudflare.com/cache/how-to/purge-cache/
Need advice on websites, software or security?
Describe the problem, and HVSC engineers will discuss the scope and options suited to your business.
FAQ
Do I Need to Change Hosting to Use Cloudflare?
Not required. Cloudflare sits in front of your existing server. But you should check SSL compatibility and cache configuration.
Why Is the Site Still Slow After Enabling a CDN?
It may be due to processing on the origin server, data queries, or heavy plugins. A CDN mainly helps with static files.
Should I Cache Entire Pages?
Only for pages that rarely change. Cart, account, and admin pages must be excluded.
- iPhone with full storage: back up first, then clean up, to avoid losing data
- Black Friday 2026: How to Tell Real Deals from Fake Ones Before You Buy
- Cài phần mềm trên Ubuntu: apt, snap và những lưu ý khi cập nhật













▶
▶
▶
▶
▶