Sub topic 9
Testing Previews and Refreshing Caches
This chapter assumes you can read basic HTML, know the difference between absolute and relative URLs, and understand HTTP requests and responses. You will learn how to check what a crawler sees, use platform debugging tools, and refresh a stale preview.
Why previews go stale
A platform does not fetch your page every time someone shares a link. It fetches the page once, stores the title, description, and image, and reuses that data. If you change your tags later, the old card can keep appearing for hours or days.
This means a good test has two parts. First, check that your HTML is correct. Second, force the platform to fetch it again.
Step 1: Check the raw HTML with curl
Crawlers usually do not run JavaScript. If a tag is added in the browser by a script, the crawler never sees it. The browser's inspector shows the page after scripts run, so it can mislead you.
Use curl to see the response a crawler gets:
curl -s -A "facebookexternalhit/1.1" https://example.com/cold-coffee | grep -i 'property="og:'The -s flag hides progress output. The -A flag sets the user agent, which is the name the client sends to identify itself. Some sites return different HTML to different crawlers, so use a crawler-like name.
A healthy result looks like this:
<meta property="og:title" content="How to Brew Cold Coffee">
<meta property="og:type" content="website">
<meta property="og:url" content="https://example.com/cold-coffee">
<meta property="og:image" content="https://example.com/images/cold-coffee-1200x630.jpg">
<meta property="og:description" content="A simple method for smooth cold-brew coffee at home.">If nothing prints, the tags are missing from the server response. Look for these causes:
- The tags are injected by client-side JavaScript.
- The request was redirected to a login page.
- The server blocked the user agent.
Add -I to see only headers, or -L to follow redirects and check the final page. Confirm that the status is 200 and that og:image points to a file that also returns 200.
Step 2: Check the image
Most broken cards are caused by the image. Request it directly:
curl -s -I https://example.com/images/cold-coffee-1200x630.jpgCheck that the status is 200, that content-type starts with image/, and that the URL is absolute and public. An image behind authentication or on a private network cannot be fetched by the platform.
Step 3: Use platform debugging tools
Each platform offers a tool that fetches your URL the way its own crawler does and shows the parsed result.
| Platform | Tool | What it does |
|---|---|---|
| Facebook and Instagram | Sharing Debugger (Meta) | Shows parsed tags, warnings, and a "Scrape Again" button |
| Post Inspector | Shows the preview and re-fetches the page | |
| X (Twitter) | Post composer preview | Shows the card as you draft a post |
Tool names and availability change over time, so check each platform's current documentation. The workflow stays the same: paste the URL, read the warnings, and fix what they report.
Step 4: Refresh the cache
After you fix the tags, ask the platform to fetch the page again.
- Open the platform's debugger.
- Paste the exact URL people will share.
- Run the fetch again (for example, "Scrape Again" in the Sharing Debugger).
- Confirm the new title and image appear.
Messaging apps often have no debugger. For those, a common workaround is to add a throwaway query string such as ?v=2. The platform treats this as a different URL and fetches it fresh. Use this only for testing, because og:url should still point to your canonical (preferred) address.
Quick troubleshooting table
| Symptom | Likely cause | Fix |
|---|---|---|
| No preview at all | Tags missing from server HTML | Render tags on the server, then re-check with curl |
| Old title or image | Cached data | Re-scrape in the debugger or rename the image |
| Image not shown | Relative URL, non-200 status, or private file | Use an absolute public URL and test it with curl |
| Wrong URL in card | `og:url` differs from the shared page | Set `og:url` to the canonical address |
Exercise
You changed your page's og:image to a new photo, but a social platform still shows the old one. The curl command shows the new tag in the HTML. What should you do next?
Show answer
The HTML is correct, so the platform's cache is the problem. Run the URL through that platform's debugger and re-scrape it. If the old image still appears, check that the new image URL returns a 200 status and consider giving the file a new name so the platform cannot reuse the cached copy.
Exercise
Why can the browser's inspector show og tags that curl does not?
Show answer
The inspector shows the page after JavaScript has run, while curl shows the raw server response. Most crawlers read only the raw response, so tags added by client-side scripts are invisible to them.