Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions assets/js/phoenix/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ import Timer from "./timer"
* @param {number} [opts.longPollFallbackMs] - The millisecond time to attempt the primary transport
* before falling back to the LongPoll transport. Disabled by default.
*
* Clients without WebSocket support fall back to LongPoll, and this includes search
* engine crawlers, whose renderers do not open WebSockets. They then repeatedly request
* the LongPoll endpoint (e.g. `/live/longpoll` for LiveView), which serves no indexable
* content. Disallow that path in `robots.txt` to avoid spending crawl budget on it.
*
* @param {boolean} [opts.debug] - When true, enables debug logging. Default false.
*
* @param {Function} [opts.encode] - The function to encode outgoing messages.
Expand Down
6 changes: 6 additions & 0 deletions installer/templates/phx_static/robots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
# To ban all spiders from the entire site uncomment the next two lines:
# User-agent: *
# Disallow: /

# /live/longpoll is LiveView's fallback transport for clients that can't open a
# WebSocket, which includes search engine crawlers. It carries no indexable
# content, so disallow it to keep crawlers from spending crawl budget there.
User-agent: *
Disallow: /live/longpoll
1 change: 1 addition & 0 deletions installer/test/phx_new_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ defmodule Mix.Tasks.Phx.NewTest do

# assets
assert_file("phx_blog/priv/static/images/logo.svg")
assert_file("phx_blog/priv/static/robots.txt", ~r"Disallow: /live/longpoll")

assert_file("phx_blog/.gitignore", fn file ->
assert file =~ "/priv/static/assets/"
Expand Down