Is the structure presheaf of $\text{Spec}(A)$ a limit of presheaves? In Shafarevich's Basic Algebraic Geometry, he defines the structure presheaf on $\text{Spec}(A)$ first by $\mathcal{O}(D(f))\cong A_f$ and then $\mathcal{O}(U)=\lim_{D(f)\subset U}\mathcal{O}(D(f))$, where $f$ is an element of the ring $A$, $D(f)$ is a Zariski basic open set, $A_f$ is the localization of $A$ at the multiplicative set $\{f^n:n\in\mathbb{N}\}$, and $U$ is an arbitrary Zariski open set. Given $D(f)\subset D(g)$, he defines explicitly the map $\rho_{D(f)}^{D(g)}\mathcal{O}(D(g))\to\mathcal{O}(D(f))$ but put succinctly, it is the unique map $A_g\to A_f$ induced by the natural map $A\to A_f$ using the universal property of $A_g$.
Under this definition, we get the universal property for $\mathcal{O}(U)$ that if $R$ is any ring together with a collection of homomorphisms $\phi_f:R\to A_f$ for each $D(f)\subset U$ such that these maps commute with the homomorphisms $\rho_{D(f)}^{D(g)}$, then there exists a unique homomorphism $u:R\to\mathcal{O}(U)$ such that $\phi_f=\rho_{D(f)}^U\circ u$ for all $D(f)\subset U$.
However, this implies a universal property about $\mathcal{O}$ itself: If $F$ is any presheaf of $\text{Spec}(A)$ with restriction maps $res_V^U:F(U)\to F(V)$, such that $F(D(f))$ is naturally isomorphic to $A_f$ for all $f$, then there exists a unique natural transformation $\eta:F\to\mathcal{O}$ such that $res_{D(f)}^U=\rho_{D(f)}^U\circ\eta_U$ for any $D(f)\subset U$ (modulo the natural isomorphism $F(D(f))\cong A_f\cong\mathcal{O}(D(f))$). This suggests to me that there should be a way to write $\mathcal{O}$ as a limit of presheaves, but it is not clear to me how to do that. So my question is, is it possible to express $\mathcal{O}$ as a limit of presheaves (in a nontrivial way) and if so, how?
Question also asked on MathOverflow
Edit: I think I came up with a way to translate the universal property into limits. Specifically, $\mathcal{O}$ is the terminal object in a certain category.
Let $\mathcal{B}$ be the poset of basic open sets of $\operatorname{Spec}(A)$, and let $\mathbf{Psh}(X)$ denote the category of presheaves on a category. Let $r:\mathbf{Psh}(\operatorname{Spec}(A))\to\mathbf{Psh}(\mathcal{B})$ be the functor which restricts a presheaf on $\operatorname{Spec}(A)$ to the basic open sets, and let $\mathcal{O}_{basic}$ be the presheaf on $\mathcal{B}$ which sends $D(f)$ to $A_f$ (i.e. the structure sheaf only on basic open sets). Lastly, let $\mathbf{C}$ be the full subcategory of the comma category $r/\mathcal{O}_{basic}$ for which the morphisms to $\mathcal{O}_{basic}$ are isomorphisms (i.e. the objects of $\mathbf{C}$ are pairs $(\mathcal{F},\phi)$ where $\mathcal{F}$ is a presheaf on $\operatorname{Spec}(A)$ and $\phi$ is a natural isomorphism from $r(\mathcal{F})$ to $\mathcal{O}_{basic}$). Then $\mathcal{O}$ is the terminal object of $\mathbf{C}$. I don't know if there is a better way to express the universal property I stated as a limit than this, but I would be happy to hear it if there is.
There are two other ways to express $\mathcal{O}$ as a limit of presheaves or sheaves which I now know (neither or which is a direct translation of the universal property I stated). The first is to use the left adjoint to the restriction $\mathbf{Sh}(\operatorname{Spec}(A))\to\mathbf{Sh}(\mathcal{B})$ as explained in John's answer. The other way is to take Shafarevich's limit definition of $\mathcal{O}(U)$ as a limit and use the fact that a limit of presheaves is computed component-wise. Explicitly, let $F:\mathcal{B}\to\mathbf{Psh}(\operatorname{Spec}(A))$ be the functor which takes an open set $D(f)$ and sends it to the presheaf given by $F(D(f))(U)=A_f$ if $D(f)\subseteq U$ and $F(D(f))(U)=0$ otherwise. The restriction maps are all either the identity map or the zero map. Then
$$\left(\lim_{D(f)\in\mathcal{B}} F(D(f))\right)(U)=\lim_{D(f)\in\mathcal{B}}F(D(f))(U)=\lim_{D(f)\subseteq U}A_f=\mathcal{O}(U)$$
and thus, $\lim_{D(f)\in\mathcal{B}}F(D(f))=\mathcal{O}$.
 A: One way to capture your intuition here, I think, is that $\mathscr{O}$ is somehow "fully determined" by its values on distinguished affine subsets $D(f) \subseteq \operatorname{Spec} A$.  One way to make this intuition precise is to show that the category of sheaves on the Zariski site of $\operatorname{Spec} A$ is equivalent to the category of sheaves on distinguished affine site of $\operatorname{Spec} A$.  This equivalence is discussed in $\S13.3$ of Vakil's Foundations of Algebraic Geometry, for example. (Don't be put off by the chapter number! The prerequisites for this subsection are really just the definition of sheaves on a scheme.)  In particular, this captures your observation that if $F$ is a presheaf on the Zariski topology that's naturally isomorphic to $\mathscr{O}$ on the distinguished affine base, then $F$ and $\mathscr{O}$ are isomorphic as (pre)sheaves on the Zariski topology.
Write $\operatorname{Sh}(Z)$ for the category of sheaves on the Zariski site and $\operatorname{Sh}(D)$ for the category of sheaves on the distinguished affine site.  The equivalence above gives a restriction map $r^{*} : \operatorname{Sh}(Z) \to \operatorname{Sh}(D)$; this is just the map sending a sheaf $F$ on the Zariski topology to the sheaf $r^{*}F$ given by $(r^{*}F)(D(f)) = F(D(f))$.  In particular, we have $(r^{*}\mathscr{O})(D(f)) = A_{f}$.  Since $r^{*}$ is an equivalence, it has a left adjoint $L : \operatorname{Sh}(D) \to \operatorname{Sh}(Z)$, and left adjoints can always be computed by limits: we have
$$
LF = \lim_{F \to (r^{*}G)} G
$$
more or less by definition of a left adjoint.  So you can write $\mathscr{O}$ as $Lr^{*}\mathscr{O}$, expressing it as a limit.  Perhaps this limit is nontrivial.
In fact there is another way to express sheaves on the Zariski site as limits.  The restriction map $r^{*} : \operatorname{Sh}(Z) \to \operatorname{Sh}(D)$ is induced by the inclusion $r : D \to Z$ of the distinguished affine site into the Zariski site.  Since $D$ is a dense subsite of $Z$ (more or less by definition of $Z$), the right adjoint $r_{*} : \operatorname{Sh}(D) \to \operatorname{Sh}(Z)$ is the right Kan extension, and right Kan extensions can be computed by limits.  So, for example, for any $U \subseteq \operatorname{Spec} A$ we have
$$
(r_{*}F)(U)
=
\lim_{D(f) \subseteq U}
F(D(f))
$$
In the case of $F = \mathscr{O}$ you recover the definition you started off with.
So I think that the nontrivial thing here is that the distinguished affine site $D$ is a dense sub-site of the Zariski site $Z$; this leads to the equivalence of $\operatorname{Sh}(D)$ and $\operatorname{Sh}(Z)$ in the particularly simple form that Shafarevich uses to define the structure presheaf on $\operatorname{Spec} A$.  Note that none of this depends on the fact that $X = \operatorname{Spec} A$ is affine, and so the structure sheaf of any scheme $X$ is the sheaf in $\operatorname{Sh}(Z)$ corresponding to the tautological sheaf $F$ acting as $F(\operatorname{Spec} A) = A$ on the distinguished affine site.  Of course, usually one defines the distinguished affine site of a scheme $X$ by reference to the structure sheaf $\mathscr{O}_{X}$, so this really is pretty tautological.
