This week, the AI world turned its gaze toward Beam, a new model that's stirring conversations about the next wave of generative AI. But while the world is talking about models, we're talking about the systems that bring them to life - specifically, how we balance the immediacy of content delivery with the strategic power of scheduling.
At Apex Grid, we're building a publishing pipeline that bridges the gap between immediate content delivery and scheduled publishing. Our platform, Postiz, handles both: scheduling social posts to hit user timezones precisely, and publishing long-form content on a cron-fire. The challenge? Ensuring consistency across channels, especially when dealing with canonical URLs.
The Problem: Consistency Across Channels
When content is published immediately, it's straightforward - the URL is fixed, and it's shared across all platforms. But when content is scheduled, the URL might not be available until the post is published. This creates a disconnect between the scheduled post (which may be shared on social media with a placeholder URL) and the final published article (which has its own canonical URL).
The result? A fragmented user experience, broken links, and a lack of trust in the content's integrity. For a technical audience, this is more than a UX issue - it's a data integrity problem.
Our Approach: Hybrid Publishing with Smart Routing
Our solution is a hybrid publishing model that leverages both scheduled and immediate publishing. For social media, we schedule posts based on user timezones using a cron-based system that respects local time zones. For long-form content, we publish immediately using a webhook-driven architecture.
The key lies in our internal routing system, which maps scheduled posts to their canonical URLs once the content is published. This system uses a lightweight event-driven architecture, where each scheduled post is associated with a content ID that's resolved at publish time.
Here’s a simplified version of our routing logic in Python:
from datetime import datetime, timezone
import pytz
def resolve_canonical_url(post_id):
# Fetch the canonical URL from the database based on the post ID
canonical_url = database.query("SELECT canonical_url FROM posts WHERE id = ?", (post_id,))
return canonical_url[0] if canonical_url else None
def schedule_post(post_id, timezone_str):
tz = pytz.timezone(timezone_str)
now = datetime.now(timezone.utc)
scheduled_time = now.astimezone(tz).replace(hour=10, minute=0, second=0, microsecond=0)
scheduled_time_utc = scheduled_time.astimezone(timezone.utc)
# Schedule the post to be published at scheduled_time_utc
scheduler.add_job(
publish_post,
trigger='date',
run_date=scheduled_time_utc,
args=[post_id]
)
def publish_post(post_id):
canonical_url = resolve_canonical_url(post_id)
if canonical_url:
# Update the scheduled post with the canonical URL
database.update("UPDATE scheduled_posts SET canonical_url = ? WHERE post_id = ?", (canonical_url, post_id))
# Trigger the webhook to publish the long-form content
webhook_client.send(f"https://api.postiz.com/webhooks/publish/{post_id}")
else:
# Handle error: no canonical URL found
logger.error(f"Could not find canonical URL for post ID {post_id}")
Tradeoffs: Flexibility vs Complexity
This hybrid approach gives us the flexibility to schedule posts for optimal engagement while ensuring that all content is published with a consistent canonical URL. However, it adds complexity to our system - we now have to manage two different publishing workflows and ensure that the mapping between scheduled posts and canonical URLs is always accurate.
We also have to be careful with time zones and cron scheduling, which can be a pain point for any system that needs to respect local time. Our current solution uses the pytz library to handle time zone conversions, but we're always on the lookout for more robust, future-proof alternatives.
What's Next
We're currently working on a new feature that will allow users to preview scheduled posts with their canonical URLs before they're published. This will help reduce errors and improve the user experience for our content creators. We’re also exploring ways to unify the scheduling and publishing workflows into a single, more intuitive interface.
What do you think about the tradeoffs between scheduling and immediate publishing in content platforms? Have you faced similar challenges in your projects?
Top comments (1)
tr.ee/dev-to